Skip to content

Components: Add fallback units for input slider in BoxControl - #70288

Merged
im3dabasia merged 9 commits into
WordPress:trunkfrom
im3dabasia:fix/box-control-fallback-units
Oct 22, 2026
Merged

im3dabasia merged 9 commits into
WordPress:trunkfrom
im3dabasia:fix/box-control-fallback-units

Conversation

@im3dabasia

@im3dabasia im3dabasia commented Jun 2, 2025 •

Copy link
Copy Markdown
Contributor

What?

Closes #61410

Stops the BoxControl slider from saving numbers without a unit.

Why?

When a side had no unit yet, moving the slider saved values like 5 instead of 5px. This happened on first use, after a reset, and when switching from a preset to a custom value.

How?

  • Fall back to the first unit in units when neither the value nor the selected unit provides one.
  • On reset, store only the units of the reset values, not the full values.
  • Add tests for an em-only list, reset, resetting to mixed values, an empty axis, and switching from a preset.

Screenshots or screencast

Before

Screen.Recording.2025-06-02.at.2.40.05.PM.mov

After

Screen.Recording.2025-06-02.at.2.40.05.PM.mov

@im3dabasia
im3dabasia requested a review from ajitbohra as a code owner June 2, 2025 09:16
@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Jun 3, 2025
@im3dabasia
im3dabasia force-pushed the fix/box-control-fallback-units branch from 1a8b3b2 to b7170ce Compare June 3, 2025 08:57
@im3dabasia
im3dabasia requested a review from a team as a code owner October 20, 2026 06:45
@im3dabasia im3dabasia self-assigned this Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @giannis-koulouris-bb.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: giannis-koulouris-bb.

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: Tropicalista <tropicalista@git.wordpress.org>
Co-authored-by: albanyacademy <brumack@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to add changelog entry

Comment thread packages/components/src/box-control/index.tsx Outdated
@im3dabasia
im3dabasia requested a review from ciampo October 20, 2026 12:30
Comment thread packages/components/src/box-control/box-input-control.tsx

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Needs a rebase before merging.

Comment thread packages/components/CHANGELOG.md
@im3dabasia
im3dabasia enabled auto-merge (squash) October 22, 2026 10:41
@im3dabasia
im3dabasia merged commit 9695f65 into WordPress:trunk Oct 22, 2026
82 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Box Control range slider doesn't set a unit initially

3 participants