-
Notifications
You must be signed in to change notification settings - Fork 47.4k
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
Reset of select ignores defaultValue #11010
Comments
@ZeHiro I'm seeing that if I click the button to reset the form without changing the value at all, it sets the value of the select element to "First". If I first change the select's value to "First" and then click reset, nothing happens (what you're reporting). Can you verify that you're seeing the same behavior? Thanks! |
@aweary I have exaclty thie behaviour. I would expect for both situations that after clicking the reset button, the "Default" option is selected. |
Thanks for confirming @ZeHiro! According to the HTML spec, select elements should do the following when a reset event happens:
So it looks like it depends on the
I think what we need to do is utilize the |
Thanks for analysing more deeply the subject. I cannot help you to chose the most appropriate solution though :-) |
No worries, I'm mostly just documenting it for future reference and for the rest of the team 😉 Thanks again for the report! |
Thanks for adressing it. |
@sebmarkbage I remember you had opinions about |
React |
Do you want to request a feature or report a bug?
I report a bug.
What is the current behavior?
When resetting a form which contains a select with a defaultValue, the selected option becomes the first option element in the list, not the one with value=defaultValue.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/ebsrpraL/).
I have put a piece of code here :
https://codepen.io/zehiro/pen/YrxZWw?editors=1111#0
Click on the reset button, which just does a form.reset() on the form.
What is the expected behavior?
I expect the select to select the option with value=defaultValue (like applying a form.reset() on a
<input/>
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React-DOM 15.6.2.
It seems to be browser independent (tried with Chromium 61 and firefox 55 for Fedora).
I didn't try this on prior version of React.
The text was updated successfully, but these errors were encountered: