-
Notifications
You must be signed in to change notification settings - Fork 839
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
[EuiFieldNumber] Invalid sign disappear for non-integer value after 7 digits #7180
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
It's the number you're using, The reason for this is sorta documented by MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#step
So I think what Chrome/Safari is basically doing is saying "good enough this is an integer" and rounding up which makes it satisfy the whole number step requirement. Also fun fact this behavior happens on webkit browsers but not Firefox so I was real confused for a second there trying to repro what you were describing 💀 |
Ah, at first I recalled some math theory about Cantor and decimal numbers which can get approximate to integers but then I thought it wasn't that. Apparently browsers decided to have a similar approach! TIL Thanks for looking into it @cee-chen ! |
No problem! Just to make sure I'm on the same page as you, would you be for/against EUI smoothing over default browser |
It would be nice to handle this, but I understand that it might be a non-trivial task. At least I have a reference now to pass over in case somebody logs an issue about that. 👍 |
IMO, it's fairly low effort to do! Should be a basic |
step
validation
step
validationstep
validation
Famous last words - this was mostly trivial up until I started edge case testing (i.e., instantiating an input with an initial In any case, new working behavior should be in #7202 / https://eui.elastic.co/pr_7202/#/forms/form-controls#number-field if you'd like to test via the playground flyout! |
🤦 So, I definitely should have anticipated this happening, but it turns out all of this was for nothing lol, because even with the updated logic, with enough 9's (e.g. Pretty sure this is just related to the JS language itself rounding integers (e.g. try pasting @dej611 I think I'm just going to close out my open PR - I don't love the idea of adding that much extra code for something that doesn't really work. If someone does log an issue for this, please feel free to point them at this thread. I'm going to do a little housecleaning on this issue to make it a little clearer what our decision was. |
step
validation
Describe the bug
If the
EuiNumberField
is configured withstep=1
then the integer validation works up to 7 digits after the dot.From the 8th digit onward the value becomes valid again 💥
Environment and versions
To Reproduce
Steps to reproduce the behavior:
95.99
and the error should appear.95.99999999
Expected behavior
The invalid icon remains.
Screenshots
The text was updated successfully, but these errors were encountered: