Skip to content

MenuItem: Match the info text color to the label in pressed items - #87153

Merged
mirka merged 4 commits into
trunkfrom
fix/menuitem-pressed-info-forced-colors
Nov 26, 2026
Merged

mirka merged 4 commits into
trunkfrom
fix/menuitem-pressed-info-forced-colors

Conversation

@mirka

@mirka mirka commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What?

Follow-up to #86393.

Gives the info text of a pressed MenuItem the same color as the item's label, in normal and forced colors modes.

Why?

The info text keeps its own gray (#6e6e6e) on a pressed item, so it doesn't follow the pressed colors that the label uses:

  1. In normal mode, it sits on the dark pressed fill (#1e1e1e) at about 3.3:1 contrast. On a disabled pressed item, it is darker than the disabled label, so it looks enabled.
  2. In forced colors mode, Components: Show pressed state of Button and Toolbar in forced colors mode #86393 made pressed buttons opt out of forced colors so they can show the pressed state with the system selection colors. The opt-out is inherited, so the info text keeps the same gray on the SelectedItem fill, or on the GrayText fill when the item is disabled with disabled or aria-disabled.

How?

The info text of a pressed item inherits the button's color in every color mode, as MenuItem already does for the info text of highlighted and expanded items.

Testing Instructions

  1. Run Storybook and open the MenuItem "With Info" story.
  2. Set isPressed to true. The description text has the same color as the "Menu Item 1" label on the dark pressed fill.
  3. In the Elements panel, add aria-disabled="true" to the button. The description has the same disabled color as the label. Replace it with disabled, and the result is the same.
  4. Remove the attribute. In Chrome DevTools, open More tools > Rendering and set "Emulate CSS media feature forced-colors" to active.
  5. The description has the same color as the label on the pressed fill. Repeat the aria-disabled and disabled checks, and the description still matches the label on the gray fill.
  6. Set isPressed to false, in both modes. The description looks the same as on trunk.
  7. Optionally repeat the forced colors checks with "Emulate CSS media feature prefers-color-scheme" set to dark, and in Firefox with forced colors turned on.

Screenshots or screencast

A pressed item and a pressed aria-disabled item, in normal mode and in forced colors mode with light and dark system colors.

Before After
Normal mode before: the description of the pressed item is gray on the dark fill, and the description of the disabled pressed item is darker than its label. Normal mode after: both descriptions have the same color as their labels, light on the dark fill and light gray on the disabled fill.
Light forced colors before: the descriptions of both pressed items are gray, on a light blue fill and on a dark red fill. Light forced colors after: the descriptions are black on the light blue fill and white on the dark red fill, matching their labels.
Dark forced colors before: the descriptions of both pressed items are gray, on a light blue fill and on a green fill. Dark forced colors after: the descriptions are black on both fills, matching their labels.

Pressed buttons opt out of forced colors so they can show the system
selection fill. The info text kept its own color on that fill, so it
now inherits the label's color.
@mirka mirka added the [Type] Bug An existing feature does not function as intended label Nov 20, 2026
@mirka mirka self-assigned this Nov 20, 2026
@github-actions github-actions Bot added the [Package] Components /packages/components label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 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: 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.


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: +23 B (0%)

Total Size: 8.73 MB

📦 View Changed
Filename Size Change
build/scripts/edit-site/index.min.js 384 kB -125 B (-0.03%)
build/styles/components/style-rtl.css 18.6 kB +18 B (+0.1%)
build/styles/components/style-rtl.min.css 15.8 kB +56 B (+0.36%)
build/styles/components/style.css 18.7 kB +19 B (+0.1%)
build/styles/components/style.min.css 15.8 kB +55 B (+0.35%)

e5e5ee9 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric c7ba133 trunk % Change
timeToFirstByte 36.3 ms +5.65% -2.07% 35.65 ms +9.82% -3.93% 1.82%
largestContentfulPaint 60 ms +6.67% -6.67% 56 ms +10.71% -0% 7.14%
lcpMinusTtfb 23.4 ms +9.62% -11.75% 21.15 ms +5.2% -3.55% 10.64%
wpBeforeTemplate 18.88 ms +7.42% -2.33% 18.26 ms +8.71% -4.22% 3.4%
wpTemplate 13.93 ms +7.18% -2.66% 14 ms +6.5% -6.5% -0.5%
wpTotal 33.12 ms +6.31% -1.66% 32.56 ms +10.44% -3.59% 1.72%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric c7ba133 trunk % Change
timeToFirstByte 31.8 ms +9.43% -5.82% 30.7 ms +10.42% -3.09% 3.58%
largestContentfulPaint 60 ms +3.33% -6.67% 56 ms +7.14% -0% 7.14%
lcpMinusTtfb 26.2 ms +4.58% -2.86% 25.8 ms +1.74% -3.1% 1.55%
wpBeforeTemplate 16.99 ms +18.72% -3.47% 16.66 ms +18.01% -3.54% 1.98%
wpTemplate 11 ms +6.36% -5.09% 10.86 ms +5.89% -4.79% 1.29%
wpTotal 28.93 ms +9.44% -6.22% 27.78 ms +11.05% -2.23% 4.14%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric c7ba133 trunk % Change
mediaProcessingJpeg 231.01 ms +0.73% -0.78% 224.04 ms +1.64% -2.36% 3.11%
mediaProcessingAvif 3733.65 ms +0.16% -0.09% 3677.06 ms +0.38% -0.18% 1.54%
mediaProcessingJpegToAvif 2616.96 ms +0.74% -0.66% 2517.06 ms +0.43% -0.26% 3.97%

media-upload

Metric c7ba133 trunk % Change
jpegUploadProcessing 1459.24 ms +1.37% -1.36% 1422.41 ms +1.41% -0.89% 2.59%
pngUploadProcessing 245.65 ms +6.38% -8.77% 189.84 ms +7.25% -3.01% 29.4%
largeJpegUploadProcessing 1451 ms +1.34% -0.64% 1437.66 ms +0.79% -1.39% 0.93%
multipleImageUploadProcessing 1495.74 ms +2.51% -0.35% 1472.96 ms +0.9% -1.17% 1.55%

post-editor

Metric c7ba133 trunk % Change
serverResponse 464.36 ms +6.64% -5.41% 485.09 ms +1.72% -6.29% -4.27%
firstPaint 427.06 ms +9.84% -5.73% 417.51 ms +6.89% -2.53% 2.29%
domContentLoaded 820.33 ms +2.35% -1.08% 834.64 ms +0.93% -1.13% -1.71%
loaded 821.4 ms +2.35% -1.08% 835.76 ms +0.93% -1.15% -1.72%
firstContentfulPaint 465.1 ms +5.2% -2.5% 474.62 ms +0.64% -3.14% -2.01%
firstBlock 2243.39 ms +0.5% -2.07% 2269.42 ms +1.08% -0.84% -1.15%
type 17.74 ms +10.43% -2.25% 18.24 ms +3.84% -3.07% -2.74%
typeWithoutInspector 16.43 ms +15.22% -4.99% 18.34 ms +5.94% -8.78% -10.41%
typeWithTopToolbar 23.85 ms +6.58% -5.41% 23 ms +8.83% -10.04% 3.7%
typeContainer 8.91 ms +26.26% -14.25% 8.85 ms +5.2% -16.05% 0.68%
focus 109.66 ms +2.54% -5.65% 114.63 ms +4.57% -5.08% -4.34%
firstFocus 260.81 ms +0% -0% 271.28 ms +0% -0% -3.86%
selectAll 411.61 ms +0.42% -3.36% 406.02 ms +3.07% -1.49% 1.38%
undo 31.56 ms +4.47% -7.7% 31 ms +7.61% -5.26% 1.81%
listViewOpen 39.65 ms +12.13% -2.82% 38.16 ms +5.71% -3.07% 3.9%
inserterOpen 42.99 ms +17.96% -8.79% 43.25 ms +6.94% -1.55% -0.6%
inserterHover 12.18 ms +7.31% -5.75% 11.19 ms +14.39% -6.88% 8.85%
inserterSearch 8.61 ms +5.81% -8.83% 8.55 ms +7.95% -3.98% 0.7%
loadPatterns 689.61 ms +4.22% -6.64% 617.72 ms +10.91% -5.32% 11.64%
wpTotal 454.78 ms +6.73% -5.52% 475.52 ms +1.68% -6.46% -4.36%
wpMemoryUsage 14.81 MB +0% -0% 14.76 MB +0% -0% 0.33%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric c7ba133 trunk % Change
serverResponse 256.38 ms +6.31% -0.73% 264.97 ms +3.84% -4.88% -3.24%
firstPaint 324.39 ms +6.44% -18.62% 334.41 ms +5.17% -10.17% -3%
domContentLoaded 576.34 ms +4.88% -4.36% 596.79 ms +0.97% -4.56% -3.43%
loaded 577.24 ms +4.86% -4.35% 597.68 ms +0.97% -4.56% -3.42%
firstContentfulPaint 326.12 ms +14.76% -4.29% 349.22 ms +0.75% -5.11% -6.61%
firstBlock 1798.13 ms +2.22% -4.36% 1788.76 ms +4.1% -1.36% 0.52%
type 12.47 ms +6.17% -8.1% 13.02 ms +9.06% -11.67% -4.22%
navigate 91.82 ms +6.99% -8.76% 80.07 ms +21.11% -4.13% 14.67%
loadPatterns 1003.86 ms +10.1% -9.33% 949.78 ms +9.52% -3.04% 5.69%
loadPages 926.82 ms +2.48% -2.35% 917.34 ms +2.87% -1.75% 1.03%
wpTotal 250.12 ms +6.44% -0.9% 258.6 ms +3.8% -5.1% -3.28%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

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

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:48:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:91:4
shows a Global Styles scale and lets a heading override it in /test/e2e/specs/editor/various/block-transform.spec.ts, passed after 1 failed attempt.
Error: Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-transform.spec.ts:280:6

e5e5ee9 Run

@mirka mirka changed the title MenuItem: Keep info text readable in pressed items in forced colors mode MenuItem: Match the info text color to the label in pressed items Nov 20, 2026
@mirka
mirka marked this pull request as ready for review November 26, 2026 15:14
@mirka
mirka requested a review from a team as a code owner November 26, 2026 15:14
@github-actions
github-actions Bot requested review from aduth and ciampo November 26, 2026 15:14

@ciampo ciampo 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.

LGTM 🚀

@mirka
mirka enabled auto-merge (squash) November 26, 2026 16:11
@mirka
mirka merged commit bc5a2bc into trunk Nov 26, 2026
84 checks passed
@mirka
mirka deleted the fix/menuitem-pressed-info-forced-colors branch November 26, 2026 16:29
@github-actions github-actions Bot added this to the Gutenberg 24.6 milestone Nov 26, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…rdPress#87153)

* MenuItem: Keep info text readable in pressed items in forced colors mode

Pressed buttons opt out of forced colors so they can show the system
selection fill. The info text kept its own color on that fill, so it
now inherits the label's color.

* Add changelog link and remove comment

* Match the info color to the label in pressed items in every color mode

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

2 participants