-
Notifications
You must be signed in to change notification settings - Fork 49.1k
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
If an input
element has the type="number"
attribute, the value
attribute in the html will only be updated on blur. However, this isn't the case if the input element has the type text
.
You can check it here: https://codesandbox.io/s/yk4zrm9pz
(Just open the Developer Tools and have a look at the DOM elements while changing the values.)
Why do I need this?
From react side everything seems to be correct (on the first look). The onChange handler is getting fired and the value is changed when updating it via setState
. But if the step
attribute is changed during stepping up and down with the browser input arrows or the keyboard arrow keys, then it's not always stepping the correct step value. And that's just because the DOM element doesn't have the correct value in the value attribute.
Here's an example: https://codesandbox.io/s/3ql999xo8p
(Just step down (with the down arrow key) and the up again.)
What is the expected behavior?
The value
attribute of the DOM element should also update on change if the input type is number
.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Latest react version (16.4.0)
Tested in Chrome and Firefox on macOS and Windows