I've had a look at a couple of other issues here on SO, without success (like Antd Select Search Box not rendering the matches).
Basically,
const AutoCompleteMultiple = ({
onSelect,
placeholder,
filter,
width = '100%',
...rest
}) => {
const [loadMembers, { loading, data }] = useLazyQuery(withGroupsQuery);
const variables = {...};
const options = data ? parseMembers(data) : [];
console.log(options);
return (
<StyledSelect
mode="multiple"
// labelInValue
filterOptions={false}
style={{ width: '100%' }}
placeholder={placeholder}
onFocus={() =>
loadMembers({
variables: {
search: '',
...variables,
},
})
}
onSearch={search =>
loadMembers({
variables: {
search,
...variables,
},
})
}
onSelect={(selected, option) => {
if (onSelect) {
onSelect(selected, option.label, option.group);
} else {
console.info(
'SelectMultipleGroupOrUserField – onSelect',
selected,
option
);
}
}}
// notFoundContent: loading ? <Spin size="small" /> : 'Inga resultat',
loading={loading}
>
{(options &&
options.map(item => (
<Select.Option value={item.value} key={item.value}>{item.label}</Select.Option>
))) ||
[]}
</StyledSelect>
);
};
In the console log, I first get the onFocus loaded data items, then when searching I get one undefined and then the correct data post search - although, the component rerenders with "No data", regardless of the option update.
I'm losing my mind.