Skip to content

Components: Synchronize popup hover and keyboard targets - #85487

Merged
ciampo merged 7 commits into
trunkfrom
codex/popup-single-highlight
Oct 28, 2026
Merged

ciampo merged 7 commits into
trunkfrom
codex/popup-single-highlight

Conversation

@ciampo

@ciampo ciampo commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #84583. This PR targets trunk independently.

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 SELECT action for hovered results. MenuItem calls the consumer's onMouseMove handler first. A handler that manages focus must call event.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

  1. In DropdownMenu Default, open the menu with a pointer and hover its second item. Focus should move to that item. Press ArrowUp, then Enter, and check that the keyboard target activates.
  2. Repeat with With Children and Single Selection. Existing hover previews should still work. In Multi Selection, click an item to keep the menu open, then hover another item and check that focus follows it.
  3. Hover a disabled menu control. It should receive focus but remain unavailable for activation.
  4. In a scrolling menu, hover a partially visible item. It should gain focus without scrolling the menu.
  5. In the editor, open slash completion and hover a different result. It should become selected while text focus stays in the editor. Press ArrowDown, then Enter, and check that the selected result is applied.
  6. Open LinkControl, type a search, and hover a result. Focus should remain in the input so you can keep typing.
  7. In With Children, give an item an onMouseMove handler that calls event.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

  1. Open DropdownMenu with the keyboard. Arrow navigation and Enter should still work. Escape should dismiss the menu and return focus to the trigger.
  2. Hover a menu item, then use arrow keys while leaving the pointer still. Focus should stay on the keyboard target until the pointer moves again.
  3. In slash completion, use arrow keys while leaving the pointer over another result. The selected result should remain the keyboard target, and Enter should apply it.

Use of AI Tools

Implemented, reviewed, and verified with Codex. I reviewed the changes and remain responsible for them.

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

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

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>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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

📦 Bundle size

Size Change: +122 B (0%)

Total Size: 8.56 MB

📦 View Changed
Filename Size Change
build/scripts/components/index.min.js 329 kB +122 B (+0.04%)

19be46a Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 84b9ec7 trunk % Change
timeToFirstByte 60.3 ms +10.45% -4.48% 56.05 ms +4.55% -2.77% 7.58%
largestContentfulPaint 100 ms +4% -8% 96 ms +6.25% -4.17% 4.17%
lcpMinusTtfb 36.9 ms +5.42% -2.71% 36.9 ms +12.2% -4.74% 0%
wpBeforeTemplate 31.37 ms +14.85% -4.27% 29.81 ms +5.4% -2.82% 5.23%
wpTemplate 24.44 ms +3.03% -8.63% 21.86 ms +4.53% -2.47% 11.8%
wpTotal 55.95 ms +10.99% -4.99% 52.19 ms +5.04% -2.64% 7.2%
wpMemoryUsage 7.70 MB +0% -0% 7.67 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 84b9ec7 trunk % Change
timeToFirstByte 50.8 ms +7.97% -2.76% 48.95 ms +2.15% -5.41% 3.78%
largestContentfulPaint 108 ms +5.56% -1.85% 104 ms +3.85% -1.92% 3.85%
lcpMinusTtfb 58.6 ms +2.05% -3.58% 55.45 ms +4.06% -1.71% 5.68%
wpBeforeTemplate 28.27 ms +7.25% -2.12% 27.54 ms +9.66% -2.18% 2.65%
wpTemplate 18.61 ms +5.32% -3.6% 16.58 ms +6.03% -2.41% 12.24%
wpTotal 47.45 ms +6.83% -3.35% 45.63 ms +1.67% -5.28% 3.99%
wpMemoryUsage 6.39 MB +0% -0% 6.36 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 84b9ec7 trunk % Change
mediaProcessingJpeg 405.43 ms +1.28% -0.6% 407.21 ms +0.95% -1.54% -0.44%
mediaProcessingAvif 6116.67 ms +0.18% -0.04% 6103.84 ms +0.3% -0.21% 0.21%
mediaProcessingJpegToAvif 4219.74 ms +0.22% -0.09% 4232.94 ms +0.01% -0.19% -0.31%

media-upload

Metric 84b9ec7 trunk % Change
jpegUploadProcessing 1446.76 ms +2.31% -0.65% 1432.52 ms +0.93% -0.58% 0.99%
pngUploadProcessing 226.41 ms +23.66% -17.37% 224.11 ms +6.8% -16.12% 1.03%
largeJpegUploadProcessing 1435.42 ms +0.41% -0.86% 1460.08 ms +0.62% -0.69% -1.69%
multipleImageUploadProcessing 1540.85 ms +0.94% -2.04% 1551.39 ms +1.66% -0.47% -0.68%

post-editor

Metric 84b9ec7 trunk % Change
serverResponse 503.17 ms +10.37% -2.64% 504.69 ms +7.65% -3.09% -0.3%
firstPaint 473.67 ms +7.33% -30.55% 496.79 ms +1.47% -36.7% -4.65%
domContentLoaded 877.22 ms +1.4% -2.06% 873.73 ms +0.38% -2.11% 0.4%
loaded 878.36 ms +1.41% -2.05% 874.95 ms +0.4% -2.12% 0.39%
firstContentfulPaint 495.19 ms +2.72% -4.38% 500.35 ms +1.67% -3.63% -1.03%
firstBlock 2969.15 ms +1.71% -1.05% 2997.32 ms +0.87% -1.62% -0.94%
type 17.39 ms +2.82% -2.82% 17.96 ms +7.24% -3.9% -3.17%
typeWithoutInspector 18.2 ms +4.07% -7.2% 17.19 ms +5.24% -5.35% 5.88%
typeWithTopToolbar 22.41 ms +1.07% -2.23% 22.4 ms +9.78% -6.7% 0.04%
typeContainer 8.2 ms +6.59% -9.76% 8.9 ms +8.43% -8.88% -7.87%
focus 120.14 ms +7.42% -5.97% 112.23 ms +11.39% -2.82% 7.05%
firstFocus 239.16 ms +0% -0% 218.61 ms +0% -0% 9.4%
selectAll 492.06 ms +1.44% -1.52% 470.6 ms +0.13% -3.23% 4.56%
undo 33.13 ms +11.62% -5.34% 31.34 ms +7.18% -3.8% 5.71%
listViewOpen 83.26 ms +4.22% -11.35% 79 ms +17.01% -4.46% 5.39%
inserterOpen 44.54 ms +3.3% -7.23% 41.44 ms +6.44% -7.63% 7.48%
inserterHover 11.09 ms +15.33% -10.46% 10.95 ms +8.04% -10.96% 1.28%
inserterSearch 8.77 ms +8.78% -5.13% 8.74 ms +6.06% -16.82% 0.34%
loadPatterns 648.67 ms +0.67% -7.54% 607.66 ms +7.67% -2.61% 6.75%
wpTotal 493.24 ms +10.73% -2.56% 494.89 ms +7.84% -3.17% -0.33%
wpMemoryUsage 14.75 MB +0% -0% 14.72 MB +0% -0% 0.24%
wpDbQueries 55 +0% -1.82% 55 +0% -1.82% 0%

site-editor

Metric 84b9ec7 trunk % Change
serverResponse 324.79 ms +0.81% -9.68% 309.71 ms +8.29% -3.83% 4.87%
firstPaint 187.76 ms +17.53% -9.83% 230.84 ms +24.95% -5.29% -18.66%
domContentLoaded 680.76 ms +1.4% -3.18% 723.39 ms +0.85% -1.74% -5.89%
loaded 681.66 ms +1.38% -3.21% 724.28 ms +0.86% -1.74% -5.88%
firstContentfulPaint 376.07 ms +8.86% -3.15% 423.54 ms +0.78% -3.69% -11.21%
firstBlock 3009.98 ms +1.15% -2.49% 3121.31 ms +0.32% -1.08% -3.57%
type 15.61 ms +3.84% -4.42% 15.87 ms +2.84% -3.21% -1.64%
navigate 102.21 ms +11.67% -5.71% 114.98 ms +7.2% -15.84% -11.11%
loadPatterns 1040.98 ms +5.47% -9.22% 942.49 ms +20.09% -8.04% 10.45%
loadPages 1018.3 ms +4.73% -1.72% 1027.85 ms +1.11% -2.17% -0.93%
wpTotal 316.57 ms +0.99% -9.79% 301.57 ms +8.42% -3.97% 4.97%
wpMemoryUsage 12.77 MB +0% -0% 12.74 MB +0% -0% 0.24%
wpDbQueries 44 +2.27% -0% 44.5 +1.12% -1.12% -1.12%

19be46a Run

🏁 Flaky tests

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.

Navigates the items list via UP/DOWN arrow keys in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByLabel('Page Two')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByLabel('Page Two') with timeout 5000ms
  - waiting for getByLabel('Page Two')
    14 × locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-181-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-181-label" aria-describedby="view-list-0-181-description"></button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:146:49
Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 2,
+   "offset": 2,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
can be converted when nested to paragraphs in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

  <!-- wp:paragraph -->
- <p>one</p>
+ <p>e</p>
  <!-- /wp:paragraph -->

  <!-- wp:paragraph -->
  <p>two</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:417:52
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
should create paragraph on Enter in quote block in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('option', { name: 'List', exact: true })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:751:67
should create paragraph on split at end and merge back with content in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

@@ -1,8 +1,8 @@
  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>one</li>
+ <li>ne</li>
  <!-- /wp:list-item --></ul>
  <!-- /wp:list -->

  <!-- wp:paragraph -->
  <p></p>

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:461:52
should indent and outdent a list item when its content is fully selected in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 5
+ Received  + 1

  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>a<!-- wp:list -->
- <ul class="wp-block-list"><!-- wp:list-item -->
- <li>b</li>
- <!-- /wp:list-item --></ul>
- <!-- /wp:list --></li>
+ <li>b</li>
  <!-- /wp:list-item --></ul>
  <!-- /wp:list -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:819:52
should indent and outdent level 1 in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')
    - locator resolved to <button id="_r_1l_" type="button" tabindex="-1" aria-label="Indent" aria-disabled="true" data-toolbar-item="true" data-truly-disabled="false" aria-describedby="components-button__description-26" class="components-button components-toolbar-button is-compact has-icon">…</button>
  - attempting click action
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
    - waiting 20ms
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
      - waiting 100ms
    18 × waiting for element to be visible, enabled and stable
       - element is not enabled
     - retrying click action
       - waiting 500ms

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:775:3
should indent and outdent level 2 in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:933:3
should insert a line break on shift+enter in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>a<br></li>
+ <li><br></li>
  <!-- /wp:list-item --></ul>
  <!-- /wp:list -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1210:52
should keep a full selection when outdenting nested items with Shift+Tab in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')
    - locator resolved to <button id="_r_1l_" type="button" tabindex="-1" aria-label="Indent" aria-disabled="true" data-toolbar-item="true" data-truly-disabled="false" aria-describedby="components-button__description-26" class="components-button components-toolbar-button is-compact has-icon">…</button>
  - attempting click action
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
    - waiting 20ms
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
      - waiting 100ms
    18 × waiting for element to be visible, enabled and stable
       - element is not enabled
     - retrying click action
       - waiting 500ms

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1166:3
should keep the list type when indenting an ordered list item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

@@ -1,8 +1,8 @@
  <!-- wp:list {"ordered":true} -->
  <ol class="wp-block-list"><!-- wp:list-item -->
- <li>one<!-- wp:list {"ordered":true} -->
+ <li>ne<!-- wp:list {"ordered":true} -->
  <ol class="wp-block-list"><!-- wp:list-item -->
  <li>two</li>
  <!-- /wp:list-item --></ol>
  <!-- /wp:list --></li>
  <!-- /wp:list-item --></ol>

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:916:52
should merge a following sibling list into the outermost list with Delete from a nested item (#77245) in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

@@ -8,11 +8,11 @@
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
-                   "content": "b‸",
+                   "content": "b",
                  },
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
@@ -25,11 +25,11 @@
    },
    Object {
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "‸1",
          },
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2854:41
should replace the selection across blocks with an inline image in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

@@ -1,9 +1,9 @@
  Array [
    Object {
      "attributes": Object {
-       "content": "ab",
+       "content": "b",
      },
      "name": "core/paragraph",
    },
    Object {
      "attributes": Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:2421:41
should split into two with paragraph and merge lists in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 1
+ Received  + 1

@@ -1,8 +1,8 @@
  <!-- wp:list -->
  <ul class="wp-block-list"><!-- wp:list-item -->
- <li>one</li>
+ <li>ne</li>
  <!-- /wp:list-item -->

  <!-- wp:list-item -->
  <li></li>
  <!-- /wp:list-item -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:502:52
should undo split in one go in /test/e2e/specs/editor/various/splitting-merging.spec.js, passed after 1 failed attempt.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8891/wp-json/wp/v2/posts?per_page=100&status=publish%2Cfuture%2Cdraft%2Cpending%2Cprivate%2Ctrash
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 735932bbf0
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_da433b7faafd8180ebeb1624ceeeab7e=admin%7C1793355546%7CD8LpiQoVlBj3BryYDPQsJWMdpEoe8BbZm9k4RRYeqIH%7Cb24ef11374ac19ff5315457f91593b5e34c3f3414b11f6265a29b6ddc285b293; wp-settings-time-1=1793183326

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:111:39)
    at RequestUtils.deleteAllPosts (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/posts.ts:30:27)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/splitting-merging.spec.js:12:22
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

Truncated. See the full report.

19be46a Run

Copilot AI 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.

🟢 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

@ciampo ciampo added the [Type] Bug An existing feature does not function as intended label Oct 23, 2026
@ciampo ciampo self-assigned this Oct 23, 2026
@ciampo
ciampo marked this pull request as ready for review October 23, 2026 22:19
@ciampo
ciampo requested a review from a team as a code owner October 23, 2026 22:19
@ciampo ciampo added Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Oct 23, 2026

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 SELECT on hover, the way FormTokenField already does in onSuggestionHovered.
  • DropdownMenu: move focus to the hovered menu item, the way the Ariakit Menu and @wordpress/ui Menu do.

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.

@ciampo
ciampo force-pushed the codex/popup-single-highlight branch from d0d32b6 to 2318cf2 Compare October 27, 2026 12:04
@ciampo

ciampo commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@mirka I switched to updating menu focus and Autocomplete selection on mouse movement. The matching filled-highlight adjustment in #84583 remains a separate follow-up.

@ciampo
ciampo requested a review from mirka October 27, 2026 12:16
@ciampo ciampo changed the title Components: Give keyboard targets priority over popup hover styles Components: Synchronize popup hover and keyboard targets Oct 27, 2026

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@ciampo
ciampo force-pushed the codex/popup-single-highlight branch from 2318cf2 to 9261270 Compare October 27, 2026 17:14
@ciampo
ciampo requested review from mirka and a balanced review from Copilot October 28, 2026 00:50

Copilot AI 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.

🟡 Changes recommended

Repeated mousemoves can override the consumer-directed focus target and cause focus to alternate, which the current regression test does not cover.

1 open issue

Review effort: Balanced

@ciampo
ciampo force-pushed the codex/popup-single-highlight branch from 4762025 to 153aac3 Compare October 28, 2026 01:11

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Everything else looks good now 👍

@ciampo
ciampo force-pushed the codex/popup-single-highlight branch from 153aac3 to 19be46a Compare October 28, 2026 10:13
@ciampo
ciampo merged commit a91cfa3 into trunk Oct 28, 2026
85 checks passed
@ciampo
ciampo deleted the codex/popup-single-highlight branch October 28, 2026 10:33
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 28, 2026
@github-actions

Copy link
Copy Markdown

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.

# Checkout the wp/7.2 branch instead of trunk.
git checkout wp/7.2

# Create a new branch for your PR.
git checkout -b my-branch

# Cherry-pick the commit.
git cherry-pick a91cfa3bafa1aec63d22fca043068adaf43df652

# Check which files have conflicts.
git status

# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue

# Push the branch to the repository
git push origin my-branch

# Create a PR and set the base to the wp/7.2 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

ciampo added a commit that referenced this pull request Oct 28, 2026
…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>
@ciampo

ciampo commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Manually backported in #85829

@ciampo ciampo added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Oct 28, 2026
Mamaduka pushed a commit that referenced this pull request Oct 28, 2026
* 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>
@Mamaduka Mamaduka removed the Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) label Oct 28, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [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.

4 participants