-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Issue with input[type=number] rendering decimal points #11606
Comments
I cannot reproduce this with either React 15.x or React 16.x. |
I can reproduce this with the webpackbin |
@TryingToImprove This seems to be related with webpackbin. If you put the following line: |
Hey @vamsiampolu! Thanks for the report! This was a long standing issue with number inputs in Chrome that was fixed by a handful of PRs. All of that work shipped with 15.6.x and 16.x. Ultimately, there is only so much we can do with number inputs. Invalid numbers report as an empty string and tampering with input validation could cause unexpected behavior. However we think our current solution resolves all of the critical edge cases. There is nothing we can do about typing If there is an edge case we've missed, please let us know! Otherwise feel free to give version 15.6.x or 16.x a shot! |
@nhunzaker Correct me if I'm wrong, but it means we are unable to control the state when invalid input is entered? Example: https://codesandbox.io/s/yw13k4wn19 Try to enter Update: |
@svagi It's triggering a change event for me. I've only tested in FF and Chrome however. Edit: Your example is correctly triggering from my testing. |
@nhunzaker Chrome 63 |
Is it possible that this is a typo, and you mean But in short, you're correct In Chrome, we can't control invalid values on number inputs because Chrome reports an empty string no matter what.. The input reports |
It's also possible I just displayed some American ignorance of using commas as decimal places :). I apologize :(. |
Do you want to request a feature or report a bug?
I would like to report a bug.
What is the current behavior?
When I use the
<input type=number />
, there is an issue with it displaying one additional decimal point. I noticed that the initial value in state is1.2
, when I type in a.
at the end of the input1.2.
is displayed while the value in state still remains1.2
. When I type in another.
at the end, the value disappears and returns an empty string instead.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).
Demo: https://www.webpackbin.com/bins/-KzQwHM22gvWWpedlwg0
What is the expected behavior?
The expected behaviour is either that the input performs no built in validation or that the validation is restrictive enough to disallow the second dot, or if the validation cannot be modified, one must ensure that the second dot changes the value back to the value without the second dot.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
This has affected me in React versions: 15.3 and 15.4, I have not tried this in React 16. I have only tried this in Google Chrome v61 and have not tried this in any of the other browsers.
The text was updated successfully, but these errors were encountered: