tbleckert / react-select-search

⚡️ Lightweight select component for React

Home Page:https://react-select-search.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Select item on Enter

romikforest opened this issue · comments

Is it possible to make this component allow me to select the item just pressing Enter when I already have fully typed it in the search area? Doesn't work in my case for some reason and I have to click the item in the dropdown list with a mouse.

I have this same issue, if you search and then move down the items using the arrow keys and then pressing enter to select doesn't work

+1 On this issue. It seems like it uses the index from the original options array, instead of the filtered version. Let's say this is the original options array:

[
    {name: 'Apple', value: 1, index: 0},
    {name: 'Boy', value: 2, index: 1},
    {name: 'Cat', value: 3, index: 2},
    {name: 'Dog', value: 4, index: 3},
    {name: 'Airplane', value: 5, index: 4},
]

Then type A to filter the options down to:

[
    {name: 'Apple', value: 1, index: 0},
    {name: 'Airplane', value: 5, index: 1},
]

When you press enter to make a selection, you end up getting:

 {name: 'Boy', value: 2, index: 1},

from the original options, instead of the filtered options array

+1 On this issue. It seems like it uses the index from the original options array, instead of the filtered version. Let's say this is the original options array:

[
    {name: 'Apple', value: 1, index: 0},
    {name: 'Boy', value: 2, index: 1},
    {name: 'Cat', value: 3, index: 2},
    {name: 'Dog', value: 4, index: 3},
    {name: 'Airplane', value: 5, index: 4},
]

Then type A to filter the options down to:

[
    {name: 'Apple', value: 1, index: 0},
    {name: 'Airplane', value: 5, index: 1},
]

When you press enter to make a selection, you end up getting:

 {name: 'Boy', value: 2, index: 1},

from the original options, instead of the filtered options array

I also have this exact issue, was also mentioned in #264

Fixed in v4.17 by #265