tbleckert / react-select-search

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

Bug: search + getOptions bug #107

Closed davidangel closed 3 years ago

davidangel commented 3 years ago

CodeSandbox Reproduction: https://codesandbox.io/s/react-select-search-bug-29g70?file=/src/App.js

When utilizing search and a custom getOptions method, it seems that clicking a result doesn't set the value, but that keyboard navigating with the Enter key does set the value.

andreymoser commented 3 years ago

I am getting the same issue and the Enter event worked for me too, the clicking is not working too.

maidul98 commented 3 years ago

Me too, please fix this

aronedwards91 commented 3 years ago

Seems to be an issue from 2.0.4 onward

tonuegbu commented 3 years ago

Still having this issue. Should I just install an older version?

tonuegbu commented 3 years ago

@davidangel please what is the solution to this?

maidul98 commented 3 years ago

@davidangel just use https://www.npmjs.com/package/react-select instead. It's better than this so I just switched my thing to that. Easy switch too

agustingabiola commented 3 years ago

Investigating the onMouseDown trigger the difference is that when you do a search the value of the option is undefined. So when you do send e.target.value down to onSelect it's undefined.

To fix this I set the value manually and still trigger the event for all the other stuff (close on click, ie)

andreymoser commented 3 years ago

I am currently using a beta version (https://github.com/andreymoser/react-select-search/releases/tag/v2.0.6-beta-107) which is working good, it's based on @davidangel 's PR (https://github.com/tbleckert/react-select-search/pull/108) with minor changes, but I guess we will have to dig up it a lit bit more to have confidence that this fix is good. 🚀

ivan-kleshnin commented 3 years ago

@maidul98 react-select depends on the big Emotion library. If you care about performance, it's not a good choice. Unless your app is already styled with Emotion of course.

tbleckert commented 3 years ago

Sorry for the delay and thanks @davidangel for the bugfix. I've merged it (just tweaked it a bit to work with numeric values) into master. Can be tested here https://react-select-search.com/?path=/story/async--fetch . Published a patch v2.1.1.

@andreymoser Nice! Let me know if you found anything else that is included in your fixes that I've missed.