-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
NumberControl: Infinity isn't a valid value for min and max #69022
Comments
Looks like the gutenberg/packages/components/src/number-control/index.tsx Lines 232 to 233 in af2915f
|
You’re right, @mirka! Using "Infinity" and "-Infinity" as HTML attribute values for min and max is invalid. For an unrestricted numeric input, the best practices might be:
I think Both the second and third approaches seem to work well, but I’m a bit unsure about which one would be the best choice. If these seem to work. I would like to work on this! |
Why not the first approach, as @afercia suggested in the description? I think that would be the standard way to do it.
|
Missed that 😅. Thanks for the suggestion! I'll create a PR and test it. |
Hi @mirka, @afercia, and @hbhalodia, I've created the PR implementing the solution and tested it. Would appreciate it if you could test and review the PR. Thank you! |
I'd agree they should be entirely omitted.
@mirka not sure where the |
@afercia I was thinking about this part: gutenberg/packages/components/src/number-control/index.tsx Lines 82 to 91 in e992acf
To be fair, it looks like |
Description
Discovered while investigating #68599 and similar issues.
By default, the
NumberControl
component and other components that extend it e.g. UnitControl > ValueInpu > NumberControl useInfinity
and-Infinity
for the min and max HTMl attributes values.That is: the rendered HTML attribute values is:
max="Infinity"
min="-Infinity"
Those aren't valid values, it's invalid HTML.
I'm not sure what was the reasoning about using
Infinity
as default value. Shouldn't themax
andmin
attributes be simply omitted to allow infinite values?Reference:
https://html.spec.whatwg.org/multipage/input.html#the-min-and-max-attributes
https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number)
Cc @WordPress/gutenberg-components
Step-by-step reproduction instructions
max="Infinity"
andmin="-Infinity"
.Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
The text was updated successfully, but these errors were encountered: