Fix loading options (onFocus > onDropdownVisibleChange).

onFocus is only triggered when when dropdown doesn't have focus where
onDropdownVisibleChange is always triggered when opening / closing the
dropdown.

Closes #334.
This commit is contained in:
Orne Brocaar 2024-05-03 12:42:33 +01:00
parent 3ec9ee2031
commit c51653d1bc

View File

@ -31,7 +31,11 @@ function AutoComplete({ placeholder, className, value, getOption, getOptions, on
}
}, [value, getOption]);
const onFocus = () => {
const onVisibleChange = (open: boolean) => {
if (!open) {
return;
}
getOptions("", options => {
if (option !== undefined) {
const selected = option.value;
@ -63,7 +67,7 @@ function AutoComplete({ placeholder, className, value, getOption, getOptions, on
<Select
showSearch
options={options}
onFocus={onFocus}
onDropdownVisibleChange={onVisibleChange}
onSearch={onSearch}
onSelect={onSelectFn}
filterOption={false}