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

input type="number" onChange vs onInput #11142

Closed
tkrotoff opened this issue Oct 6, 2017 · 1 comment
Closed

input type="number" onChange vs onInput #11142

tkrotoff opened this issue Oct 6, 2017 · 1 comment

Comments

@tkrotoff
Copy link

tkrotoff commented Oct 6, 2017

With <input type="number">, when entering text ("eee"), onChange is not fired, onInput is.
https://codepen.io/tkrotoff/pen/gGvvxw

Tested with React 16 + Chrome 61, Firefox 55, Safari 10.1.1 and Edge 38.14

DOM behavior (no React): https://codepen.io/tkrotoff/pen/RLQQqo

React onChange is not equivalent to DOM input event as it should.

tkrotoff added a commit to tkrotoff/react-form-with-constraints that referenced this issue Oct 7, 2017
tkrotoff added a commit to tkrotoff/react-form-with-constraints that referenced this issue Oct 7, 2017
@aweary
Copy link
Contributor

aweary commented Oct 7, 2017

Hey, @tkrotoff this is a known limitation for number inputs, see #6556. React will only emit a change event when the value of the input has actually changed, and when you enter an invalid number in a number input you get a value of '' from the DOM, so 123ee and 123eee both have a value of '' and a change event won't be dispatched since React cannot detect the change. Hope that helps!

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