You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m working with react-select in my project and I want to prevent the Select component from gaining focus after clearing the value. Using the actionMeta prop with the select ref is not working because the select is focused again after the blur.
As you can see, right after the onBlur is executed, the onFocus is executed too, so I don't know if there's a racing condition happening or some event propagation that I'm not aware of.
One workaround that I found was to put the selectRef?.current?.blur() call inside a setTimeout function.
Any tips or suggestions would be awesome! Thanks in advance!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey everyone!
I’m working with react-select in my project and I want to prevent the Select component from gaining focus after clearing the value. Using the actionMeta prop with the select ref is not working because the select is focused again after the blur.
Here’s what I have so far:
https://codesandbox.io/p/sandbox/82rkp7
As you can see, right after the
onBlur
is executed, theonFocus
is executed too, so I don't know if there's a racing condition happening or some event propagation that I'm not aware of.One workaround that I found was to put the
selectRef?.current?.blur()
call inside a setTimeout function.Any tips or suggestions would be awesome! Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions