Skip to content

Padding controls behave inconsistently with fractional pixels #73083

@dsas

Description

@dsas

Description

The editor padding controls (BoxControl?) rounds fractional pixels - enter 14.8 and it'll change it to 15 on blur. However if you first change the units and then set them back again to pixels it will allow the fractional pixels to remain.

tl;dr:

  • The rounding behaviour is only applied on blur
  • The validation message is subtle and hardly likely to be seen

Step-by-step reproduction instructions

  1. In the site editor select a block that supports dimensions / padding
  2. Under Dimensions → Padding in the block sidebar, press the button to allow manual value entry
  3. Enter a value in fractional pixels e.g 3.14
  4. Tab out - note the value is reset to 3
  5. Click px and change the units to em
  6. Enter 3.14 again
  7. Change the units back to px, note it says 3.14
  8. Hover over the input and it will tell you 3.14 is an invalid value.
  9. Hit save and reload, note the 3.14px is preserved
  10. Click inside the input and click out again, note the 3.14 is rounded to 3

Screenshots, screen recording, code snippet

Screen.Recording.2025-11-07.at.12.38.50.mov

Environment info

Tested on GB trunk (5db7f24) with Firefox 144.0.2. It's also visible in the BoxControl storybook.

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

No one assigned

    Labels

    [Package] Components/packages/components[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