tbleckert / react-select-search

⚡️ Lightweight select component for React
https://react-select-search.com
MIT License
674 stars 149 forks source link

Wrong highlight indexing. #264

Closed mmuric closed 9 months ago

mmuric commented 11 months ago

Describe the bug I'm using useSelect to create select box, and I encountered on the problem. When you try to search any word, and after that when you try to select option with up and down key, if you keep pressing down key highlight will disappear. Also, if you start pressing up/down key and try to select an option, it may result in a different selection.

To Reproduce

  1. Go to your storybook here.
  2. In a input type "Bul", it will show 4 options.
  3. If you keep pressing down key, highlight will go till the end of the list which is "Syrian Arab Republic", and than it will skip to unknown, or disappear.
  4. Also if you select "Bulgaria" selected result will be something like Albania.

Expected behavior I expected that highlight will start over from top. And that I can select option that I want.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context I'm not 100% sure, but I think that in this line of code, instead of passing options, you should pass something like you return in snapshot.

jwmann commented 10 months ago

I also have this bug.

If you do a fuzzy search and you find the one you want: Clicking on the result works as expected. However, if you use the keys to go down and then press Enter on the result, it will take the index on the results list but grab the index from the options lists.

index 0 from the results are not the same as index 0 from the options.

tbleckert commented 9 months ago

Fixed in v4.1.7 by https://github.com/tbleckert/react-select-search/pull/265