Skip to content

NumberControl: Infinity isn't a valid value for min and max #69022

@afercia

Description

@afercia

Description

Discovered while investigating #68599 and similar issues.

By default, the NumberControl component and other components that extend it e.g. UnitControl > ValueInpu > NumberControl use Infinity 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 the max and min 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)

The min attribute, if specified, must have a value that is a valid floating-point number. The max attribute, if specified, must have a value that is a valid floating-point number.

Cc @WordPress/gutenberg-components

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Package] Components/packages/components[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions