-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Number input not firing onChange #10370
Comments
Can you provide a reproduction in a jsfiddle or other similar tool? cc @nhunzaker |
Tried on jsfiddle, but it works there, strange |
<input type="number"
className="form-control"
value={typeof this.state.value !== 'undefined' && this.state.value !== null ? this.state.value : ''}
onChange={e => this.onChange(e.target.value)} /> onChange(value) {
const VALUE = parseFloat(value);
this.setState({ value: VALUE >= 0 && !isNaN(VALUE) ? value : '' });
} |
It is odd that it would work with JSFiddle but not for you locally. type=number may only work with the HTML 5 doctype. Did you specify HTML 5? (This is the only thing I can think without seeing more code.) |
Yes, i specified HTML 5 |
It does the same with On this codepen, if you click on "one", then "two", then "one", then "two", only the first two I tested with several HTML elements, but some of them are working (checkboxes for example). Reproducible since 15.6.0, working with previous versions. |
@Antwan86 yup we are already aware of that issue, it's unrelated to this one though |
My bad just saw the appropriate ticket. Keep up the good work! |
This is mostly a duplicate of #6556. Here's an example that can reproduce the issue. If you type |
@Antwan86 your codepen was a great example of the issue. I made a minor fork of it and pinned it to 15.5.4 to highlight the issue in the hopes that others looking for a solution find this thread. |
The issue can be reproduced with @next: https://jsfiddle.net/ugr5sp1q/ |
Since the root cause is the same, I'm going to close this as a duplicate of #10370. |
@aweary The issue can be reproduced in the v0.16.0 version: https://jsfiddle.net/d4a52zdk/. The issue can't be a duplicate of itself. You might want to reopen it. |
I don`t know if it is bug or feature, but since you put into input with type number two minuses it will stop calling
onChange
callback, but value inside input will changeReact 15.4.2
Browser Version 60.0.3112.90 (Official Build) (64-bit)
The text was updated successfully, but these errors were encountered: