Allow dropdown to stay open when multi-selecting
When multi-selecting, it would be nice if the dropdown menu stayed open after a selection to allow the user to continue selecting.
Note that you can do this yourself:
<Typeahead
multiple
onChange={(selected) => {
this._typeahead.getInstance().focus();
}}
options={[...]}
ref={typeahead => this._typeahead = typeahead}
/>
Thanks for the quick response! This is a great component. Thank you for making and maintaining it.
TLDR; Old solution didn't work, I had to use toggleMenu.
i.e.
const ref = React.useRef()
const [selected, setSelected] = React.useState([])
return (
<Typeahead
multiple
id="keep-menu-open"
onChange={(selections) => {
setSelected(selections)
ref.current.toggleMenu()
}}
options={options}
placeholder="Choose a state..."
ref={ref}
selected={selected}
/>
)
@nickgrealy great example, thank you! Here's a working sandbox link for anyone else coming across this issue:
https://codesandbox.io/s/rbt-keep-menu-open-during-multi-select-nr2y4
Select multiple options and reuse the search filtering and keep the menu open prevent control to scrolls back to top after selecting an entry