Repository navigation
Components: Synchronize popup hover and keyboard targets - #85487
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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +122 B (0%) Total Size: 8.56 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 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. Navigates the items list via UP/DOWN arrow keys in
|
There was a problem hiding this comment.
🟢 Approval recommended
The scoped selector changes preserve specificity and resting styles, with no unresolved findings.
No open issues 🎉
What changed in this PR
This PR gives keyboard targets visual priority over hovered items in DropdownMenu and Autocomplete, complementing the solid-brand popup styling work.
Changes:
- Adds a shared Sass selector that suppresses competing hover styles without increasing specificity.
- Applies the selector to Button hover rules while preserving resting styles, and documents the fix.
| File | Description |
|---|---|
packages/components/src/utils/popup-item.scss |
Defines the shared keyboard-priority hover selector. |
packages/components/src/button/style.scss |
Applies the selector to existing hover treatments. |
packages/components/CHANGELOG.md |
Records the DropdownMenu and Autocomplete fix. |
Review effort: Balanced
mirka
left a comment
There was a problem hiding this comment.
My main issue with this approach is that it's very hard to maintain over time without a vizreg setup. The responsibilities are muddy because now the popup-item utility has to know about the internal markup of multiple different components.
I think the two cues come from having two sources of "active": :hover and focus/aria-selected. Could we merge them at the source instead of reconciling them in Button's CSS?
- Autocomplete: dispatch
SELECTon hover, the way FormTokenField already does inonSuggestionHovered. - DropdownMenu: move focus to the hovered menu item, the way the Ariakit
Menuand@wordpress/uiMenudo.
Then the popup highlight in #84583 can key off :focus / [aria-selected="true"] only, and Button doesn't need to change. A row the pointer is resting on while the user arrows elsewhere would keep Button's default text-color hover, the same as on trunk, not a second filled row. The behavior is also testable without a vizreg: hover a row, then assert focus or aria-selected moved.
d0d32b6 to
2318cf2
Compare
mirka
left a comment
There was a problem hiding this comment.
CleanShot.2026-10-27.at.22-26-54.mp4
This is testing well for me. The hover style stays, but I'd say that's acceptable if it keeps the code simpler.
2318cf2 to
9261270
Compare
4762025 to
153aac3
Compare
mirka
left a comment
There was a problem hiding this comment.
Everything else looks good now 👍
153aac3 to
19be46a
Compare
|
There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch. PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk. |
…5829) * Components: Prioritize keyboard targets over popup hover styles * Fix single popup highlight changelog reference * Components: Synchronize popup hover and keyboard targets * MenuItem: Preserve consumer focus on hover * DropdownMenu: Use real pointer interaction in scroll test * MenuItem: Require explicit cancellation of hover focus * MenuItem: Keep hover focus within the active menu --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
|
Manually backported in #85829 |
* Components: Prioritize keyboard targets over popup hover styles * Fix single popup highlight changelog reference * Components: Synchronize popup hover and keyboard targets * MenuItem: Preserve consumer focus on hover * DropdownMenu: Use real pointer interaction in scroll test * MenuItem: Require explicit cancellation of hover focus * MenuItem: Keep hover focus within the active menu --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
…5487) * Components: Prioritize keyboard targets over popup hover styles * Fix single popup highlight changelog reference * Components: Synchronize popup hover and keyboard targets * MenuItem: Preserve consumer focus on hover * DropdownMenu: Use real pointer interaction in scroll test * MenuItem: Require explicit cancellation of hover focus * MenuItem: Keep hover focus within the active menu --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>

Follow-up to #84583. This PR targets
trunkindependently.What?
Make pointer movement update the active item in DropdownMenu, MenuItem, and Autocomplete.
Why?
Hover and keyboard navigation currently identify separate targets. Updating focus or selection at the source lets popup styling follow one active item.
How?
Move focus to menu items on mouse movement and dispatch Autocomplete's existing
SELECTaction for hovered results. MenuItem calls the consumer'sonMouseMovehandler first. A handler that manages focus must callevent.preventDefault()to cancel automatic focus, including when its chosen target is already focused. Non-menu roles retain their existing focus behavior. Hover focus does not scroll the item into view.The solid brand styling in #84583 still needs to use focus and selection for its filled highlight. A hovered item can retain Button's existing text-color hover when keyboard focus moves elsewhere. Initial opening focus remains separate in #85486.
Testing Instructions
onMouseMovehandler that callsevent.preventDefault()and focuses another control. Move the pointer repeatedly over the item. Focus should remain on that control, including when it was already focused.Testing Instructions for Keyboard
Use of AI Tools
Implemented, reviewed, and verified with Codex. I reviewed the changes and remain responsible for them.