Skip to content

Components: Align legacy form control focus rings with WPDS#80417

Open
ciampo wants to merge 4 commits into
trunkfrom
codex/align-legacy-form-control-focus-rings
Open

Components: Align legacy form control focus rings with WPDS#80417
ciampo wants to merge 4 commits into
trunkfrom
codex/align-legacy-form-control-focus-rings

Conversation

@ciampo

@ciampo ciampo commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Part of #80412.

What?

Aligns the shared focus ring used by legacy InputBase controls with @wordpress/ui for Phase 0 of #80412. It also prevents the DataViews filter operator SelectControl from clipping the new outset ring.

Why?

Legacy form controls need to look as close as possible to their @wordpress/ui replacements before consumer migrations begin. Their current adjacent border and box-shadow treatment differs from the UI outset ring.

Why the old style used box-shadow

Gutenberg's older focus convention combined a 1px border with a 0.5px shadow to produce the specified 1.5px stroke (#54394, #54398), when rounded outlines were not yet reliable across supported browsers. It was a consistency technique, not an InputControl requirement. Because box-shadows are not visible in Windows High Contrast Mode, the legacy style also needed a transparent outline fallback (#50772). The WPDS outline now provides the intended outset shape and forced-colors behavior directly.

How?

  • Moves the shared InputBase focus treatment from Emotion to package Sass and applies outset-ring__focus(), using the same --wpds-border-width-focus and --wpds-color-stroke-focus tokens and generated fallbacks as @wordpress/ui.
  • Preserves suppression of the input ring while an interactive prefix or suffix has focus.
  • Audits Gutenberg overrides: existing sizing, padding, typography, background, border, and validation styles remain compatible. The only clipping case was DataViews; replacing overflow: hidden with min-width: 0 preserves its flex sizing while allowing the ring to paint outside.
  • Documents the user-facing alignment in the Components changelog.

Testing Instructions

Run:

npm run lint:css
npm run lint:js -- packages/components/src/input-control/styles/input-control-styles.tsx
npm run test:unit -- packages/components/src/input-control packages/components/src/select-control packages/components/src/custom-select-control
npm run build

In Storybook and relevant editor surfaces, focus these controls and compare their outset rings with their @wordpress/ui equivalents:

Group Affected controls
Shared primitives InputControl, SelectControl, CustomSelectControl (legacy wrapper and v2 implementation)
Direct composites NumberControl, SearchControl, UnitControl, RangeControl (including its input field), AnglePickerControl, TreeSelect
Compound consumers ColorPicker, ColorPalette, CustomGradientPicker, GradientPicker, TimePicker, DateTimePicker, PaletteEdit, FontSizePicker, BorderControl, QueryControls
Validated variants ValidatedInputControl, ValidatedNumberControl, ValidatedSelectControl, ValidatedCustomSelectControl, ValidatedRangeControl

Check the behavior-sensitive cases:

  • An interactive prefix or suffix, including the UnitControl unit selector, suppresses the surrounding input ring.
  • The joined TimePicker hour/minute fields and customized PaletteEdit name field have the correct ring shape without clipping.
  • An invalid validated control keeps its error border while focus uses the WPDS focus color.
  • A DataViews filter with multiple operators does not clip the focused operator selector.
  • The ring remains visible with forced-colors emulation enabled.

Testing Instructions for Keyboard

  1. Use Tab to focus each affected form-control type and confirm a clearly visible outset ring appears.
  2. For controls with interactive prefix or suffix content, move focus to that control and confirm the input ring is suppressed without removing the auxiliary control's own focus indicator.

Screenshots or screencast

Here are a few examlpes of the change that is being applied

Before After
Screenshot 2026-07-17 at 23 55 13 Screenshot 2026-07-17 at 23 55 23
Screenshot 2026-07-17 at 23 55 39 Screenshot 2026-07-17 at 23 55 47
Screenshot 2026-07-17 at 23 56 07 Screenshot 2026-07-17 at 23 56 14
Screenshot 2026-07-17 at 23 56 58 Screenshot 2026-07-17 at 23 57 05
Screenshot 2026-07-17 at 23 57 39 Screenshot 2026-07-17 at 23 57 56
Screenshot 2026-07-17 at 23 57 45 Screenshot 2026-07-17 at 23 58 01
Screenshot 2026-07-17 at 23 59 48 Screenshot 2026-07-17 at 23 59 54
Screenshot 2026-07-18 at 00 06 50 Screenshot 2026-07-18 at 00 06 57

Use of AI Tools

Codex was used to inspect existing focus-ring patterns and history, audit affected consumers, implement the shared Sass change and clipping fix, run verification, and draft this pull request. The resulting diff and generated CSS were reviewed manually.

@github-actions github-actions Bot added the [Package] Components /packages/components label Jul 17, 2026
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

Size Change: +131 B (0%)

Total Size: 7.73 MB

📦 View Changed
Filename Size Change
build/scripts/components/index.min.js 272 kB -74 B (-0.03%)
build/styles/components/style-rtl.css 18.1 kB +49 B (+0.27%)
build/styles/components/style-rtl.min.css 15 kB +59 B (+0.39%)
build/styles/components/style.css 18.2 kB +49 B (+0.27%)
build/styles/components/style.min.css 15 kB +59 B (+0.39%)
build/styles/edit-site/style-rtl.css 21.4 kB -2 B (-0.01%)
build/styles/edit-site/style-rtl.min.css 17.5 kB -1 B (-0.01%)
build/styles/edit-site/style.css 21.4 kB -2 B (-0.01%)
build/styles/edit-site/style.min.css 17.5 kB -1 B (-0.01%)
build/styles/editor/style-rtl.css 31.3 kB -3 B (-0.01%)
build/styles/editor/style.css 31.3 kB -2 B (-0.01%)

compressed-size-action

@github-actions github-actions Bot added the [Package] DataViews /packages/dataviews label Jul 17, 2026

@ciampo ciampo Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Trying out a different approach that doesn't cut off the focus ring, but still lets SelectControl shrink inside the flex row despite white-space: nowrap

@ciampo ciampo self-assigned this Jul 17, 2026
@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Jul 17, 2026
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

Flaky tests detected in 1b83fe9.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29617798981
📝 Reported issues:

@ciampo
ciampo marked this pull request as ready for review July 17, 2026 22:07
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

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

Co-authored-by: ciampo <mciampini@git.wordpress.org>

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

@ciampo
ciampo force-pushed the codex/align-legacy-form-control-focus-rings branch from 9700694 to 1b83fe9 Compare July 17, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Package] DataViews /packages/dataviews [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant