I'm using autocomplete component to display data from remote API. After getting some items, options popup doesn't show up until focus input again, as the gif below.

options props changed, but popup does not show up
<Autocomplete
allowMultiple={true}
options={state.options}
selected={state.selectedCreators}
onSelect={handleSelectionChange}
loading={state.loading}
textField={
<Autocomplete.TextField
label="something"
onChange={handleTermChange}
value={state.term}
/>
And using a debounce to avoid request too much.
const useDebounce = (value, delay) => {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);
return () => {
clearTimeout(handler);
};
}, [value, delay]);
return debouncedValue;
};
If I use 'real' input value rather than 'debouncedValue', something works fine, but in production, it won't go with the input value.
The popup doesn't show up until focus input again.
Bump, we are also affected by this issue in Polaris 5.1.0. Thank you for the excellent writeup @keidarcy. Interestingly, this did not appear to be an issue for us in Polaris 4.21.0.
duplicate of https://github.com/Shopify/polaris-react/issues/3048
I should have closed this when mentioning it's a duplicate. So i'm doing that now.
Most helpful comment
Bump, we are also affected by this issue in Polaris 5.1.0. Thank you for the excellent writeup @keidarcy. Interestingly, this did not appear to be an issue for us in Polaris 4.21.0.