Repository navigation
UI: Use solid brand highlights for popup items - #84087
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. 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 📦 Bundle sizeSize Change: +12 B (0%) Total Size: 9.06 MB 📦 View Changed
🏁 Flaky testsSome 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. Regression: updating a specific option will only change its value and will not corrupt others in
|
|
@WordPress/gutenberg-components @WordPress/gutenberg-design @Mamaduka Here's a POC to test diffent options for hover / focus states, trying out a few alternatives:
Screen.Recording.2026-10-05.at.22.36.44.movI personally quite like the neutral version, it feels like it blends better, doesn't scream for attention and leaves the primary color for the instances where it really needs to gran the attention. |
|
Unless there are objections, I'd like to move forward with using a neutral background color for the highlight, and using a focus ring around items that receive keyboard focus (which means that in combobox-like UIs, there may be two focus rings displayed at once, but that should be ok). I plan on iterating on this tomorrow, unless there are any objections. |
The brand variant is darker because it mimics the previous active styles, basically same as solid brand buttons. For submenu parent items, I honestly haven't thought about it, so I'd be open to feedback in that case. Still, that shouldn't be an issue if we go with neutral highlights (which seems to have general consensus from what I gathered) |
4ab0f18 to
e6ffca5
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The broad cross-package focus and forced-colors behavior warrants final human browser review.
0 open findings
What changed in this PR
Standardizes popup item highlights and keyboard focus rings across @wordpress/ui and @wordpress/components.
Changes:
- Applies neutral hover/highlight colors and zero-offset focus rings.
- Tracks pointer versus keyboard interaction for composite options.
- Updates themed popup backgrounds and package changelogs.
| File | Description |
|---|---|
packages/ui/src/utils/use-popup-pointer-highlight.ts |
Tracks popup pointer interaction. |
packages/ui/src/utils/item-popup/keyboard-highlight-context.ts |
Shares keyboard-highlight state. |
packages/ui/src/utils/css/item-popup.module.css |
Updates generic popup item styles. |
packages/ui/src/menu/style.module.css |
Updates menu highlights and rings. |
packages/ui/src/menu/popup.tsx |
Adds pointer tracking to menus. |
packages/ui/src/form/primitives/select/popup.tsx |
Adds pointer tracking to selects. |
packages/ui/src/form/primitives/combobox/root.tsx |
Tracks combobox keyboard highlighting. |
packages/ui/src/form/primitives/combobox/item.tsx |
Exposes combobox highlight modality. |
packages/ui/src/form/primitives/autocomplete/root.tsx |
Tracks autocomplete keyboard highlighting. |
packages/ui/src/form/primitives/autocomplete/item.tsx |
Exposes autocomplete highlight modality. |
packages/ui/CHANGELOG.md |
Records UI package changes. |
packages/components/src/utils/hooks/use-keyboard-navigation.ts |
Adds shared navigation tracking. |
packages/components/src/utils/composite-item.scss |
Defines shared popup state styles. |
packages/components/src/utils/colors-values.js |
Adds focus and highlight tokens. |
packages/components/src/menu/styles.ts |
Updates deprecated menu states. |
packages/components/src/menu-item/style.scss |
Applies shared menu-item styles. |
packages/components/src/form-token-field/types.ts |
Adds keyboard-navigation state prop. |
packages/components/src/form-token-field/suggestions-list.tsx |
Marks keyboard-driven suggestion lists. |
packages/components/src/form-token-field/style.scss |
Updates suggestion item styling. |
packages/components/src/form-token-field/index.tsx |
Tracks suggestion interaction modality. |
packages/components/src/dropdown/style.scss |
Themes dropdown popup items. |
packages/components/src/dropdown-menu/style.scss |
Updates dropdown menu items. |
packages/components/src/custom-select-control-v2/style.module.scss |
Updates custom select option states. |
packages/components/src/combobox-control/index.tsx |
Tracks combobox interaction modality. |
packages/components/src/autocomplete/style.scss |
Updates autocomplete option states. |
packages/components/src/autocomplete/autocompleter-ui.tsx |
Tracks editor autocomplete navigation. |
packages/components/CHANGELOG.md |
Records Components package changes. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Should we split this into at least two PRs (wp-ui and wp-components)? Given the maintenance aspect, I feel like this warrants some consideration/review of the approach itself, not just the rendered result. |
|
As far as we have agreement on the overall approach, sure. I just didn't want to end up with inconsistencies again. |
|
I moved the This PR stays focused on |
|
+1 for neutral :) |
|
We could make this theme-able, like shadcn/ui. But not something to worry about here/now. |
|
@jameskoster this PR should be in a good state for a full review, it implements neutral bg/fg colors + visible focus ring (see PR description for screenshots) |
eaceeaa to
3ca82f6
Compare
mirka
left a comment
There was a problem hiding this comment.
Happy we were able to align on a solution that's not too painful! 💛
* Storybook: Compare composite focus indicators * Design system: Use neutral highlights and focus rings for popup items * Design system: Fix changelog section ordering * UI: Share popup highlight tracking and handle same-item pointer hover * UI: Keep virtual popup focus rings with the input focus * Combobox: Align popup search fields with items * Combobox: Inset option highlights without changing the search field * UI: Share input and list highlight handlers * Autocomplete: Restore focus ring at grid boundaries * UI: Extract popup option alignment for separate review * UI: Separate keyboard option rings from pointer hover * UI: Simplify active option rings to input focus * UI: Use solid brand highlights for popup items * UI: Preserve popup colors for headings and disabled links * Menu: Keep open submenu parents neutral when highlighted * UI: Restore submenu hover and join adjacent highlights * UI: Keep popup highlights on the active item --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: fcoveram <fcoveram@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org>
|
I just cherry-picked this PR to the wp/7.2 branch to get it included in the next release: d22ef52 |



See #80405. The
@wordpress/componentswork remains in #84583. Popup alignment is reviewed separately in #84935.What?
Use the same solid brand highlight for hovered and keyboard-highlighted popup items in
@wordpress/ui.Why?
Give popup items one consistent highlight without separate item focus rings or custom interaction tracking.
How?
Use the active foreground and background tokens from the solid brand Button. Supporting text, icons, and selection indicators use the same foreground. Style Base UI's active item through
[data-highlighted], so a stationary pointer does not leave a second row filled during keyboard navigation. Open submenu parents use the solid highlight while active and retain the subtle neutral background after focus moves into the submenu.Testing Instructions
#608010and background#4f386e. Enable WordPress global CSS and check RTL. In forced-colors mode, active items use the system highlight colors. Resting open submenu parents retain a thin system-color outline.Testing Instructions for Keyboard
grinning, press ArrowDown, hover the cell, and press ArrowDown again. The active cell keeps its highlight at the grid boundary.highlightItemOnHover={ false }on Menu or Combobox. Hovering another item should not add a second fill or change the keyboard target. Enter should still activate the keyboard-highlighted item.Verification
Production build, CSS lint, changelog validation, commit hooks, and 215 existing popup tests passed for the latest follow-up. Independent review found no remaining actionable issues. Chromium checks confirmed one active highlight during pointer-to-keyboard switching, Enter selection, submenu active and resting states, supporting content, disabled items, and menu links, including dark mode, WordPress global CSS, RTL, and forced colors.
Earlier Chromium checks covered all nine popup and control variants, custom themes, the autocomplete grid, heading-rendered labels, and ARIA-disabled menu links. Those checks measured highlighted text contrast at 6.00:1 in light, 4.58:1 in dark, and 5.62:1 in the custom theme. Safari, touch, screen readers, and native Windows high-contrast mode were not tested.
Screenshots or screencast
Before: trunk
5e25c6a584a. After:b70ab55e928. These popup appearances are unchanged by the later label, disabled-link, and submenu-parent fixes. Matching standalone Storybook captures at 500 × 440, cropped to the relevant content, LTR, basic global CSS. The first option is hovered.Dark theme, searchable compositions, and controls
Open submenu parent
Menu Submenu, captured at
eaceeaa5112, light theme, WordPress global CSS loaded with wp-admin/wp-core-ui classes, LTR, 900 × 480. The open parent stays light gray while a child uses the solid brand highlight. In the current implementation, the parent uses the solid brand highlight when it becomes the active item.Use of AI Tools
Under the author's direction, Codex reworked the styles, removed the earlier interaction-tracking code, rebased the branch, ran verification and an independent review, captured screenshots, addressed review feedback, and updated this description.