IIUC, we can workaround this by clearing the suggestions when a selection is made (via onSuggestionsClearRequested). However, this is not always desirable—we may want to keep the suggestions in state so they can be immediately shown again when the input regains focus.
Interesting. This issue doesn't seem to come up when using an async function to fetch results, probably because the list is fetched every time input is changed & no value corresponds to an empty suggestion list.
https://codepen.io/OliverJAsh/pen/ZEEOoZq?editors=0011
Steps to reproduce:
c
Observed behaviour:
onSuggestionSelected
is invoked at step 4, even though the list is hidden (see console logs).This doesn't seem like intuitive behaviour—how can something that is hidden be selected?
Expected behaviour: no suggestion is selected at step 4
Related: https://github.com/moroshko/react-autosuggest/issues/483
IIUC, we can workaround this by clearing the suggestions when a selection is made (via
onSuggestionsClearRequested
). However, this is not always desirable—we may want to keep the suggestions in state so they can be immediately shown again when the input regains focus.