Skip to content

DropdownMenu: Invert the selected item indicator while highlighted - #86330

Merged
mirka merged 4 commits into
trunkfrom
fix/dropdown-menu-selected-item-highlight
Nov 5, 2026
Merged

mirka merged 4 commits into
trunkfrom
fix/dropdown-menu-selected-item-highlight

Conversation

@mirka

@mirka mirka commented Nov 4, 2026

Copy link
Copy Markdown
Member

What?

Inverts the selected item's icon tile in DropdownMenu while that item is highlighted by hover or keyboard focus. The tile becomes light with a brand-colored glyph, and it returns to the dark tile when the highlight moves away.

Why?

The dark tile was designed for a plain menu background. Since popup items gained a solid brand highlight in #84583, it has about 2.4:1 contrast against the fill and reads as a stray dark block on the row. The inverted tile has about 6:1 contrast against the same fill.

How?

The tile swaps the highlight's own foreground and background tokens instead of picking a fixed color, so it follows the admin color scheme and always has the same contrast as the item's text. The alternatives were a transparent tile with an outline, which reads as a second focus ring, a translucent white tile, which looks muddy and depends on the accent color, and no tile at all, which hides the checked state on the focused item.

Testing Instructions

  1. Open a post and select a paragraph block.
  2. Open the Align block menu in the block toolbar.
  3. Hover the selected item. The icon should show as a light tile with a brand-colored glyph.
  4. Hover another item. The selected item should return to the dark tile, and the hovered item should have no tile.
  5. Choose a text alignment in the Align text menu, reopen the menu, and hover the selected item. It should show the same light tile.

Testing Instructions for Keyboard

  1. Select a paragraph block, then press Alt+F10 to move focus to the block toolbar.
  2. Use the arrow keys to reach Align block, then press ArrowDown to open the menu. The first item is focused.
  3. With None selected, confirm that it shows the light tile. Press ArrowDown and confirm that it returns to the dark tile.

Screenshots or screencast

The selected item is highlighted in each image.

State Before After
Default Align block menu with the selected None item highlighted in blue and a dark icon tile Align block menu with the selected None item highlighted in blue and a light icon tile with a blue glyph
Forced colors Forced colors mode with the selected None item highlighted and a dark icon tile Forced colors mode with the selected None item highlighted and a light icon tile

The dark tile behind a selected item's icon was designed for the plain menu
background. Since popup items gained a solid brand highlight, it has sat at
about 2.4:1 against the fill and reads as a stray dark block. Swap the
highlight's own foreground and background on the tile, so that it follows the
admin color scheme and keeps the contrast of the item's text.
@mirka mirka added [Type] Bug An existing feature does not function as intended 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 Nov 4, 2026
@mirka mirka self-assigned this Nov 4, 2026
@github-actions github-actions Bot added the [Package] Components /packages/components label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 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: mirka <0mirka00@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@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: +421 B (0%)

Total Size: 8.61 MB

📦 View Changed
Filename Size Change
build/styles/components/style-rtl.css 17.6 kB +136 B (+0.78%)
build/styles/components/style-rtl.min.css 14.7 kB +74 B (+0.51%)
build/styles/components/style.css 17.7 kB +135 B (+0.77%)
build/styles/components/style.min.css 14.7 kB +76 B (+0.52%)

2bc6c05 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric fd75fbc trunk % Change
timeToFirstByte 37.1 ms +6.6% -5.8% 36.6 ms +13.11% -4.64% 1.37%
largestContentfulPaint 64 ms +6.25% -0% 64 ms +9.38% -3.13% 0%
lcpMinusTtfb 28.3 ms +12.9% -8.66% 27.25 ms +13.76% -7.16% 3.85%
wpBeforeTemplate 18.73 ms +13.77% -2.88% 19.15 ms +9.5% -3.24% -2.19%
wpTemplate 14.2 ms +2.96% -4.72% 14.16 ms +8.55% -6.64% 0.28%
wpTotal 33.97 ms +6.83% -6.59% 33.47 ms +12.61% -4.72% 1.49%
wpMemoryUsage 7.72 MB +0% -0% 7.68 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric fd75fbc trunk % Change
timeToFirstByte 31.5 ms +9.37% -6.67% 29.9 ms +8.19% -2.34% 5.35%
largestContentfulPaint 72 ms +0% -5.56% 72 ms +8.33% -5.56% 0%
lcpMinusTtfb 39 ms +3.85% -2.56% 39.2 ms +8.93% -2.3% -0.51%
wpBeforeTemplate 16.63 ms +12.87% -2.04% 16.59 ms +3.8% -1.39% 0.24%
wpTemplate 11.01 ms +11.17% -4.09% 10.6 ms +6.04% -3.58% 3.87%
wpTotal 28.87 ms +9.63% -6.96% 27.1 ms +9.59% -1.4% 6.53%
wpMemoryUsage 6.41 MB +0% -0% 6.37 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric fd75fbc trunk % Change
mediaProcessingJpeg 231.26 ms +2.98% -1.55% 237.87 ms +3.47% -2.14% -2.78%
mediaProcessingAvif 3768.57 ms +0.16% -0.29% 3865.29 ms +0.14% -1.74% -2.5%
mediaProcessingJpegToAvif 2632.85 ms +0.18% -0.69% 2672.94 ms +1.17% -0.42% -1.5%

media-upload

Metric fd75fbc trunk % Change
jpegUploadProcessing 1420.88 ms +0.37% -0.84% 1416.22 ms +2.06% -0.67% 0.33%
pngUploadProcessing 185.28 ms +2.11% -1.57% 199.71 ms +3.3% -5.81% -7.23%
largeJpegUploadProcessing 1420.37 ms +1.65% -0.28% 1412.26 ms +0.5% -0.3% 0.57%
multipleImageUploadProcessing 1489.88 ms +0.62% -3.14% 1521.1 ms +0.88% -0.93% -2.05%

post-editor

Metric fd75fbc trunk % Change
serverResponse 475.05 ms +3.82% -7.63% 461.25 ms +5.38% -5.29% 2.99%
firstPaint 396.48 ms +21.38% -10.94% 333.56 ms +46.61% -5.1% 18.86%
domContentLoaded 871.27 ms +2.75% -1.8% 866.44 ms +2.1% -1.73% 0.56%
loaded 872.43 ms +2.74% -1.81% 867.61 ms +2.1% -1.72% 0.56%
firstContentfulPaint 518.02 ms +2.05% -4.68% 505.07 ms +3.18% -2.17% 2.56%
firstBlock 2210.05 ms +4.18% -1.32% 2204.46 ms +0.63% -0.94% 0.25%
type 16.88 ms +7.17% -2.31% 18.95 ms +6.23% -5.91% -10.92%
typeWithoutInspector 17.41 ms +8.44% -6.49% 17.65 ms +12.29% -5.78% -1.36%
typeWithTopToolbar 24.72 ms +4.13% -4.73% 24.26 ms +3.38% -9.27% 1.9%
typeContainer 9.5 ms +10.21% -17.16% 8.36 ms +9.09% -15.55% 13.64%
focus 115.61 ms +9.21% -3.56% 122.59 ms +9.34% -6.31% -5.69%
firstFocus 276.33 ms +0% -0% 260.81 ms +0% -0% 5.95%
selectAll 417.76 ms +2.42% -0.2% 405.89 ms +3.58% -0.51% 2.92%
undo 30.96 ms +6.52% -3.59% 32.34 ms +2.44% -7.45% -4.27%
listViewOpen 81.5 ms +6.8% -2.72% 83.52 ms +6.48% -9.14% -2.42%
inserterOpen 45.41 ms +2.07% -11.54% 43.67 ms +24.04% -3.25% 3.98%
inserterHover 11.3 ms +9.73% -9.65% 11.89 ms +12.87% -11.02% -4.96%
inserterSearch 8.75 ms +9.49% -9.71% 8.58 ms +8.62% -9.56% 1.98%
loadPatterns 665.72 ms +3.96% -2.45% 666.84 ms +2.99% -9.01% -0.17%
wpTotal 465.08 ms +3.94% -7.74% 451.62 ms +5.48% -5.46% 2.98%
wpMemoryUsage 14.76 MB +0% -0% 14.73 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric fd75fbc trunk % Change
serverResponse 480.64 ms +1.08% -7.91% 486.52 ms +0.78% -1.57% -1.21%
firstPaint 398.66 ms +4.39% -5.69% 388.11 ms +1.47% -6.23% 2.72%
domContentLoaded 883.99 ms +0.28% -0.87% 889.65 ms +1.32% -1.58% -0.64%
loaded 885 ms +0.31% -0.87% 890.83 ms +1.33% -1.56% -0.65%
firstContentfulPaint 512.19 ms +2.38% -0.91% 509.4 ms +1.29% -4.27% 0.55%
firstBlock 2630.3 ms +0.58% -0.24% 2642.18 ms +0.86% -0.65% -0.45%
type 19.13 ms +1.57% -9.98% 17.23 ms +3.37% -6.96% 11.03%
navigate 118.48 ms +4.77% -2.64% 116.47 ms +9.09% -4.07% 1.73%
loadPatterns 1401.73 ms +10.88% -6.4% 1308.32 ms +4.48% -2.08% 7.14%
loadPages 1019.1 ms +1.62% -3.48% 1023.17 ms +1.86% -5.63% -0.4%
wpTotal 471.17 ms +1.07% -8.16% 476.8 ms +0.81% -1.56% -1.18%
wpMemoryUsage 12.78 MB +0% -0% 12.74 MB +0% -0% 0.27%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

2bc6c05 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.

Undo restores the post selection when another synced entity is loaded 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
should place the caret at the click position when clicking a block that is not selected in /test/e2e/specs/editor/various/writing-flow.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": "First!",
+       "content": "First",
      },
      "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/writing-flow.spec.js:952:41

2bc6c05 Run

WordPress gives Dashicons a 100 ms color transition, so the glyph lagged behind
the tile background and was briefly white on the light tile.
@mirka

mirka commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

@WordPress/gutenberg-design Is this design workaround acceptable for now? 😅

@jasmussen

Copy link
Copy Markdown
Contributor

Isn't there a darker version of the brand token we can use? Perhaps if you combine that with an inversion of the icon itself, it might work. I.e.

image

Hmm, no not really.

I'd love to hear other opinions, but yes the compromise is probably fine for now, but it speaks to a problem with the toggle format instead. Which is to say in the future I'd expect this to probably be checkmark or not, rather than an added background inside the menu.

@jameskoster

Copy link
Copy Markdown
Contributor

Which is to say in the future I'd expect this to probably be checkmark

Yeah the solution is to adopt Menu from the UI package, but it's blocked by the toolbar styling work (#84567).

@t-hamano t-hamano 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.

Given that forced colors mode has no system color darker than Highlight, inverting the icon and background colors on hover or focus feels like the simplest and clearest approach.

Image

P.S. In forced colors mode, especially with a dark theme, the dark tile behind the active item's icon blends into the background, so the active state is hard to see. This predates this PR, so it could be addressed in a follow-up.

Testing on Windows High Contrast Mode:

Theme name Screenshot
Aquatic Image
Desert Image
Dusk Image
Night sky Image

@mirka
mirka marked this pull request as ready for review November 5, 2026 12:21
@mirka
mirka requested a review from a team as a code owner November 5, 2026 12:21
@mirka

mirka commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Thanks everyone for looking into this 🙏

In forced colors mode, especially with a dark theme, the dark tile behind the active item's icon blends into the background, so the active state is hard to see. This predates this PR, so it could be addressed in a follow-up.

Right, everything around the toolbar seems like it needs a forced colors pass.

@mirka
mirka enabled auto-merge (squash) November 5, 2026 12:24
@mirka
mirka merged commit bdc530c into trunk Nov 5, 2026
82 checks passed
@mirka
mirka deleted the fix/dropdown-menu-selected-item-highlight branch November 5, 2026 12:45
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

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 bdc530cfda5564155f1b1e9e5ad75a3ecbf3c5dd

# 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.

mirka added a commit that referenced this pull request Nov 5, 2026
…ighted (#86379)

* DropdownMenu: Invert the selected item indicator while highlighted (#86330)

* DropdownMenu: Invert the selected item indicator while highlighted

The dark tile behind a selected item's icon was designed for the plain menu
background. Since popup items gained a solid brand highlight, it has sat at
about 2.4:1 against the fill and reads as a stray dark block. Swap the
highlight's own foreground and background on the tile, so that it follows the
admin color scheme and keeps the contrast of the item's text.

* Add changelog link

* DropdownMenu: Switch selected Dashicon colors without a fade

WordPress gives Dashicons a 100 ms color transition, so the glyph lagged behind
the tile background and was briefly white on the light tile.

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
(cherry picked from commit bdc530c)

* Add changelog link

---------

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
@mirka mirka 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 Nov 5, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…ordPress#86330)

* DropdownMenu: Invert the selected item indicator while highlighted

The dark tile behind a selected item's icon was designed for the plain menu
background. Since popup items gained a solid brand highlight, it has sat at
about 2.4:1 against the fill and reads as a stray dark block. Swap the
highlight's own foreground and background on the tile, so that it follows the
admin color scheme and keeps the contrast of the item's text.

* Add changelog link

* DropdownMenu: Switch selected Dashicon colors without a fade

WordPress gives Dashicons a 100 ms color transition, so the glyph lagged behind
the tile background and was briefly white on the light tile.

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@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