tbleckert / react-select-search

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

[bug] When input is focused, clicking again on it result in weird behavior #98

Closed vvo closed 3 years ago

vvo commented 4 years ago

Hi there:

See: RPReplay_Final1593613306

PS: Sorry for opening so many (3) issues, I enjoy your component and I am close to having a very nice behavior, see: RPReplay_Final1593613535

tbleckert commented 4 years ago

@vvo Don't be sorry for the issues ✌️ really appreciate the testing and reporting. Had a computer free July but back in business now and going through it all. This should be a quick fix

vvo commented 4 years ago

Thanks for your reply :) Feels good to be computer free from time to time!

mazondo commented 4 years ago

fwiw, this is similar to an issue I hit, reproduction is:

This is reproducible on the storybook examples as well. The solve for me was the following on a renderValue:

useEffect(() => {
    if (search && snapshot.focus && ref.current) {
      ref.current.focus();
    }
  }, [snapshot.focus, search, ref.current])

Not sure it's the best fix, but it also resolves this reported issue. You need to make sure your renderValue is using forwardRef.