react-autosuggest
react-autosuggest copied to clipboard
Keep suggestions open after a choice is made
Is there a way to keep the suggestions open after a choice is made? Or, more generally: I want the suggestions to be open any time the input has focus.
I tried shouldRenderSuggestions={() => true}
. It doesn't accomplish this.
I have a similar case here, which is to suggest a table name with field name. So after user select a suggested table name, the suggestions then keep open to show the suggested fields inside the table. But the fact is that after click on a suggestion, it then close the suggestions list. No way to pop it again programmatically.
@jonahgreenthal have you tried https://github.com/moroshko/react-autosuggest#alwaysrendersuggestions-optional
@gilad-solter Unfortunately, simply using alwaysRenderSuggestions
does not solve the specific issue being described. The issue is that when focusInputOnSuggestionClick
is used (so that the focus is maintained), shouldRenderSuggestions
does not continue to render suggestions after a choice is made even though it should (according to its described behavior).
I agree, this is an issue. Seems to be a bug. I am looking for a work around.
Not sure if this is a perfect workaround for what you need, but it works for my use case:
const inputProps = {
onClick: (e) => {
e.currentTarget.blur();
e.currentTarget.focus();
},
};
...
<Autosuggest
inputProps={inputProps}
shouldRenderSuggestions={() => true}
/>
This blurs and refocuses the input when it's clicked, which in turn triggers the suggestions to pop up again (much like the way react-autocomplete works).