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

[EuiFieldNumber] Safari marks as invalid floating point numbers when step is not provided #5327

Closed
dej611 opened this issue Oct 27, 2021 · 7 comments
Labels

Comments

@dej611
Copy link
Contributor

dej611 commented Oct 27, 2021

I've noticed this issue while testing few components in Lens, which can be quite misleading for the user I think.

This is an example of a UI affected by this:

Screenshot 2021-10-27 at 15 58 11

the first time I saw it I thought the values were invalid somehow, but after the investigation I found it was the Safari correct about the spec. 😓

While by default the fallback value for step is the integer value 1, hence any floating point should be invalid, most browser do not respect this and let the user input any value. Safari is the only browser which implements the invalid check by the spec on this side.

(source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#step )

Safari:
Screenshot 2021-10-27 at 15 49 50

Chrome:
Screenshot 2021-10-27 at 15 54 01

Using the any step value seems to align Safari with the rest of the browsers for the validation.

I'd propose to add a any fallback for the step prop on the EuiFieldNumber component to fix this behaviour.

@dej611 dej611 added the bug label Oct 27, 2021
@chandlerprall
Copy link
Contributor

@cchaos what do you think about making any the default step in EuiFieldNumber to align browser behaviours?

Relates to #3864

@cchaos
Copy link
Contributor

cchaos commented Oct 27, 2021

Can you think of any cases where consumers who have relied on the expectancy that the default step is 1 would be dramatically affected?

@dej611
Copy link
Contributor Author

dej611 commented Oct 27, 2021

Using the palette configurator in Lens has high probability to show those invalid markers as the first 5 stops are autogenerated. Another possible common place is the new Lens reference line editor where the default value is autogenerated.
In both cases the user opens the editor for the first time and see the inputs marked in red.

@cchaos
Copy link
Contributor

cchaos commented Oct 27, 2021

Thanks @dej611 for these Lens-specific use cases. Is it not possibly to change the step="any" directly on your end versus relying on the default knowing that these values may not be integers?

My question was mostly directed towards our engineers about other general use-cases of this component as it's used 180 times in Kibana alone.

@dej611
Copy link
Contributor Author

dej611 commented Oct 28, 2021

Thanks @dej611 for these Lens-specific use cases. Is it not possibly to change the step="any" directly on your end versus relying on the default knowing that these values may not be integers?

We can solve on our side, sure.

@cee-chen
Copy link
Contributor

Closing this as not planned - since it's been a while and most consumers are used to 1 being the default step at this point, and it's also clearly documented as such in our props, our suggestion to any team that needs decimal places would be to manually change their step to "any".

@cee-chen cee-chen closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2023
@cee-chen
Copy link
Contributor

cee-chen commented May 9, 2023

After the new invalid browser styling, and after having conferred with designers, we've decided to default step to "any" after all to smooth over the default browser behavior of setting :invalid state on decimal numbers while typing but setting them to :valid on blur. See #6760

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants