Focus on first item in Downshift Typeahead

796 Views Asked by At
downshift version: 5.2.7 
node version: 12.16.2 
yarn version:1.22.4

Using the following sandbox provided on Downshift JS's website: https://codesandbox.io/s/simple-downshift-with-getrootprops-example-24s13

I'm attempting to focus on the first item in the typeahead list as I filter with:

items.filter(item => !inputValue || item.label.toLowerCase().includes(inputValue.toLowerCase()))

The filter works, however, I'm unsure how to ensure that the item that most closely matches the input is focused on. I would like the user to be able to type in the input and be able to simply hit the 'enter' key to select the top most filtered item ( or closely matching item ) whilst typing. How would I do so with the Downshift package?

0

There are 0 best solutions below