-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing state in onFocus and onChange for a select multiple element does not work in Firefox #6951
Comments
I can confirm that I see the same, apparently buggy, behavior. This only happens if we |
So is there any workaround I could use? Or can react be changed to resolve the issue? Or should I open a bug report for Firefox? Not sure where to go from here... |
Heyo! I think I actually came across some similar issues with other frameworks when dealing with multiple select boxes in Ffox. My guess is that in Ffox one triggering event stops the propagation thru to the other and therefore requires the double time click, probably cause the select box has actual children in all the options in it. |
@swpdsgn Thank you, but for me this workaround is not working well. E.g. select a line, then click somewhere else for the multiselect to loose focus, then click that already selected line again. The multiselect will receive focus again, but that will not be represented by the state. |
@skleeschulte sry about the error. That state doesn't change if you click on the same option selected, which is to be expected cause the value didn't change. For the other selectable options works ok. Now I've added an additional onClick to set the focus back if the selected option is clicked again. Check it now. |
@swpdsgn Ok, this is getting closer, but is still not working as it should: at least on Windows, the focus is normally already set on mouse-down - not only after a "full" click. |
Can somebody confirm if it still happens in React 16? |
As far as I can test, using this new jsfiddle for React 16.4.1, this is still an issue: |
Still reproduces with React 17 (and some experimental feature flags): #20810 (comment) |
I want to use a controlled
<select multiple={true} />
component in React. In addition to the value I also want to keep the focused state of the select in the state. To do this, I update the state withsetState
in theonChange
,onFocus
andonBlur
event handlers. Unfortunately there is an issue in Firefox: Firefox will only update the value on a change event after the select has gained focus. This means that a user has to click twice on the select element to change its value when it does not have focus. I would expect the select to gain focus and change the value at the same click.I created a jsFiddle to demonstrate the prolem: React select multiple issue in Firefox demonstration
I only see this problem in Firefox and with select multiple. In IE and Chrome it is working as expected, and in Firefox it is working as expected for other form elements (simple select, checkbox, radio, text input, textarea).
My environment:
The text was updated successfully, but these errors were encountered: