-
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
HTML5 number input uncontrolled mode issues when changing defaultValue #7507
Comments
I believe this is the same issue as #7253, it happens because defaultValue always gets reassigned on change: Invoked in the handleChange callback for inputs here: |
Yupp, same root cause as #7253. This isn't specific to |
Why are you closing it? You just admitted it's a legitimate bug. |
I'm not closing it because it's not a bug, I'm closing it because it's an issue we're already tracking in #7253. Having multiple issues open for variations of a root issue only serves to fragment discussion (see #7297 for another example #7253) It's not that we're ignoring it, just trying to keep our issues organized 😄 you can subscribe to #7253 to get updates on any progress made. @nhunzaker has some PRs open that seem to address this, so it might just be a matter of getting those reviewed 👍 |
Okay, thanks. |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Providing a
defaultValue
to an HTML5 number input causes the element to enter into some sort of semi-controlled mode. Changing thedefaultValue
should be a noop after the element has been mounted, but it seems to set a property in the element and break the behavior of the uncontrolled component.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
See this fiddle and try to enter
1e8
: http://codepen.io/3lux/pen/yJkWojWhat is the expected behavior?
1e8
should show up in the input box; since some DOM property is being changed when the provideddefaultValue
is changed, I think the DOM is trying to programmatically set the input to an interim value that's not a real number, like1e
and then wipes it out and resets to an empty string, which is caught in theonChange
handler and persisted back to thedefaultValue
, effectively losing the input.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Latest React, latest Chrome
The text was updated successfully, but these errors were encountered: