Skip to content
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

Bug in controlled input of type number #6900

Closed
jfremy opened this issue May 27, 2016 · 1 comment
Closed

Bug in controlled input of type number #6900

jfremy opened this issue May 27, 2016 · 1 comment

Comments

@jfremy
Copy link

jfremy commented May 27, 2016

There seems to be a bug in the way React interfaces with controlled inputs of type number

If the input contains an invalid number (let's say --2 or 2++), then trying to clear the input value by setting it to an empty string does nothing.

You can check an example to reproduce there: https://jsfiddle.net/96bnn12r/2/
The onChange handler will set the controlled value to the value returned by ev.target.value.
In the case of an invalid value, the input returns an empty string (as per html spec https://html.spec.whatwg.org/multipage/forms.html#states-of-the-type-attribute 4.10.5.1.12) so this should actually clear the input but the invalid input stays.

When setting the input value to an empty string after entering an invalid value, it should clear the input content not keep the invalid value.

Seen in React 0.14.8, 15.0.1, 15.1.0 on OSX Chrome v50, Firefox 46.0.1

@jimfb
Copy link
Contributor

jimfb commented May 27, 2016

Duplicate of #6556, related to #6368

@jimfb jimfb closed this as completed May 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants