Skip to content

UI Button: Show pressed state in forced colors mode - #85948

Merged
mirka merged 6 commits into
trunkfrom
fix/ui-button-forced-colors-pressed
Nov 5, 2026
Merged

mirka merged 6 commits into
trunkfrom
fix/ui-button-forced-colors-pressed

Conversation

@mirka

@mirka mirka commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

What?

Makes the pressed state of Button (neutral tone, minimal variant, aria-pressed="true") visible in forced colors mode.

Why?

The pressed state is conveyed only by a strong background and foreground color. Forced colors mode replaces both with system colors, so a pressed toggle looks the same as an unpressed one, and a disabled pressed toggle looks the same as a disabled unpressed one.

This is already affecting the app, for example these style variation buttons:

Style variation buttons in the block inspector

How?

Pressed buttons are filled with the system SelectedItem and SelectedItemText colors and keep the unpressed ButtonBorder border, which keeps the filled look the pressed state has outside forced colors mode and matches how Combobox items show selection in forced colors. A thicker border or an underline would also mark the state, but they are weaker cues and add shapes the button does not use elsewhere.

Testing Instructions

  1. Run Storybook and open Design System / Components / Button / Pressed.
  2. In Chrome DevTools, open Rendering and set "Emulate CSS media feature forced-colors" to active.
  3. Confirm the pressed button is filled with the selection color and its label is readable. Toggle aria-pressed off in Controls and confirm the button returns to the outlined look.
  4. Set disabled in Controls and confirm the pressed button is filled with the gray disabled color and its label is readable.
  5. Repeat with the Global CSS toolbar set to WordPress.
  6. Turn off forced colors emulation and confirm the pressed button looks unchanged.

Testing Instructions for Keyboard

  1. With forced colors emulation active, press Tab to focus the pressed button.
  2. Confirm a focus ring is visible around it.

Screenshots or screencast

Unpressed, pressed, and pressed disabled buttons with WordPress Global CSS.

Before After
Forced colors Forced colors before: the pressed button is outlined like the unpressed one Forced colors after: the pressed button is filled with the selection color, the disabled one with gray
Forced colors, pressed button focused Forced colors after: the focused pressed button has a visible focus ring
Normal colors (unchanged) Normal colors before Normal colors after, identical to before

Pressed neutral minimal buttons rely on a strong background color, which
forced colors mode discards, leaving them identical to unpressed ones.
Fill them with SelectedItem and SelectedItemText, or GrayText when disabled.
@mirka mirka added [Type] Bug An existing feature does not function as intended [Package] UI /packages/ui labels Oct 29, 2026
@mirka mirka self-assigned this Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 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: mirka <0mirka00@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@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: +609 B (+0.01%)

Total Size: 8.61 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 545 kB +69 B (+0.01%)
build/scripts/block-library/index.min.js 425 kB +87 B (+0.02%)
build/scripts/customize-widgets/index.min.js 22.8 kB +81 B (+0.36%)
build/scripts/edit-site/index.min.js 378 kB +89 B (+0.02%)
build/scripts/edit-widgets/index.min.js 29.1 kB +83 B (+0.29%)
build/scripts/editor/index.min.js 566 kB +60 B (+0.01%)
build/scripts/media-utils/index.min.js 233 kB +68 B (+0.03%)
build/scripts/notices/index.min.js 45.8 kB +72 B (+0.16%)

d7ccd69 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 043033b trunk % Change
timeToFirstByte 62.9 ms +4.05% -6.36% 58.2 ms +9.88% -5.33% 8.08%
largestContentfulPaint 104 ms +7.69% -7.69% 94 ms +10.64% -6.38% 10.64%
lcpMinusTtfb 39.15 ms +19.16% -8.81% 35.25 ms +6.38% -5.25% 11.06%
wpBeforeTemplate 32.89 ms +6.84% -5.44% 30.44 ms +11.43% -2.76% 8.05%
wpTemplate 24.7 ms +10.53% -4.13% 23.54 ms +4.55% -7.22% 4.93%
wpTotal 58.92 ms +4.19% -7.18% 53.99 ms +10.59% -5.13% 9.13%
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 043033b trunk % Change
timeToFirstByte 51.15 ms +7.33% -2.93% 50.8 ms +4.53% -8.96% 0.69%
largestContentfulPaint 108 ms +3.7% -0% 106 ms +3.77% -3.77% 1.89%
lcpMinusTtfb 57.35 ms +4.18% -1.92% 55.1 ms +4.45% -0.82% 4.08%
wpBeforeTemplate 29.2 ms +2.29% -3.46% 27.85 ms +8.22% -3.77% 4.85%
wpTemplate 18.77 ms +2.77% -4.16% 18.3 ms +5.14% -10.38% 2.57%
wpTotal 47.72 ms +7.27% -2.16% 47.34 ms +4.65% -8.94% 0.8%
wpMemoryUsage 6.41 MB +0% -0% 6.37 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 043033b trunk % Change
mediaProcessingJpeg 416.75 ms +0.8% -0.73% 405.83 ms +1.65% -0.54% 2.69%
mediaProcessingAvif 6255.04 ms +0.67% -0.04% 6191.14 ms +0.42% -0.48% 1.03%
mediaProcessingJpegToAvif 4330.33 ms +0.08% -0.15% 4270.63 ms +0.23% -0.31% 1.4%

media-upload

Metric 043033b trunk % Change
jpegUploadProcessing 1975.01 ms +2.82% -0.58% 1462.06 ms +32.01% -0.77% 35.08%
pngUploadProcessing 288.44 ms +3.39% -26.65% 178.98 ms +3.93% -10.64% 61.16%
largeJpegUploadProcessing 1472.29 ms +31.68% -0.99% 1946.95 ms +0.48% -23.46% -24.38%
multipleImageUploadProcessing 2041.71 ms +1.17% -1.16% 2044.79 ms +0.79% -0.23% -0.15%

post-editor

Metric 043033b trunk % Change
serverResponse 299.14 ms +9.93% -4.17% 298.58 ms +10.43% -1.24% 0.19%
firstPaint 287.13 ms +37.4% -4.55% 394.83 ms +3.51% -34.6% -27.28%
domContentLoaded 690.2 ms +9.35% -2% 688 ms +1.51% -1.66% 0.32%
loaded 691.13 ms +9.56% -2.03% 688.89 ms +1.52% -1.66% 0.33%
firstContentfulPaint 401.02 ms +15.01% -1.62% 400.42 ms +2.06% -1.28% 0.15%
firstBlock 1757.11 ms +6.36% -2.17% 1757.14 ms +1.01% -1.1% 0%
type 14.8 ms +6.22% -3.38% 16.26 ms +5.97% -6.21% -8.98%
typeWithoutInspector 15.44 ms +5.51% -11.66% 15.55 ms +6.62% -13.7% -0.71%
typeWithTopToolbar 19.38 ms +9.08% -4.02% 21.37 ms +5.15% -6.88% -9.31%
typeContainer 6.77 ms +0.89% -4.73% 7.06 ms +10.91% -8.22% -4.11%
focus 95.58 ms +4.38% -4.5% 95.89 ms +6.41% -3.97% -0.32%
firstFocus 198.56 ms +0% -0% 201.17 ms +0% -0% -1.3%
selectAll 305.16 ms +2.57% -1.04% 318.04 ms +1.64% -2.68% -4.05%
undo 27.67 ms +3% -9.11% 26.29 ms +5.59% -4.68% 5.25%
listViewOpen 65.2 ms +15.52% -10.11% 63.71 ms +3.61% -8.84% 2.34%
inserterOpen 35.78 ms +2.29% -3.8% 33.26 ms +2.8% -1.26% 7.58%
inserterHover 9.98 ms +9.12% -9.92% 9.32 ms +9.76% -5.79% 7.08%
inserterSearch 7.3 ms +1.92% -6.71% 7 ms +9.57% -2.14% 4.29%
loadPatterns 515.83 ms +2.55% -3.07% 511.29 ms +1.33% -3.74% 0.89%
wpTotal 290.47 ms +10.22% -4.23% 289.84 ms +10.76% -1.26% 0.22%
wpMemoryUsage 14.76 MB +0% -0% 14.73 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 043033b trunk % Change
serverResponse 270.96 ms +5.42% -8.29% 260.81 ms +5.52% -5.54% 3.89%
firstPaint 257.55 ms +3.27% -3.89% 254.94 ms +32.18% -9.66% 1.02%
domContentLoaded 611.87 ms +5.89% -1.25% 603 ms +3.45% -3.24% 1.47%
loaded 612.8 ms +5.88% -1.27% 603.81 ms +3.44% -3.23% 1.49%
firstContentfulPaint 359.96 ms +1.19% -1.36% 343.84 ms +1.66% -2% 4.69%
firstBlock 1804.76 ms +4.09% -2.78% 1752.59 ms +2.1% -1.6% 2.98%
type 14.44 ms +5.26% -6.02% 13.77 ms +8.79% -7.99% 4.87%
navigate 91.73 ms +14.06% -10.76% 75.38 ms +4.03% -3.13% 21.69%
loadPatterns 1053.27 ms +7.65% -21.19% 764.74 ms +21.52% -9.47% 37.73%
loadPages 958.17 ms +0.49% -1.72% 920.74 ms +2.71% -1.14% 4.07%
wpTotal 264.37 ms +5.43% -8.55% 254.51 ms +5.48% -5.88% 3.87%
wpMemoryUsage 12.78 MB +0% -0% 12.74 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

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

Actions are reachable via RIGHT/LEFT 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:  getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' })
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' }) with timeout 5000ms
  - waiting for getByRole('row', { name: 'Page One Edit Actions' }).getByRole('button', { name: 'Edit' })
    14 × locator resolved to <button type="button" tabindex="-1" class="components-button is-small" id="view-list-0-261-primary-action-edit-post">Edit</button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:172:5
inserts a block in proper place after having clicked `Browse All` from block appender in /test/e2e/specs/editor/various/inserting-blocks.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('button', { name: 'Browse All' })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/inserting-blocks.spec.js:709:60
inserts a block should show a blue line indicator in /test/e2e/specs/editor/various/inserting-blocks.spec.js, passed after 1 failed attempt.
TypeError: Cannot read properties of null (reading 'y')
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/inserting-blocks.spec.js:681:32
should keep correct selection when dragging outside block (-firefox) 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

  Array [
    Object {
      "attributes": Object {
-       "content": "1",
+       "content": "23",
      },
      "name": "core/paragraph",
    },
  ]

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:787:41
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

d7ccd69 Run

@mirka mirka added the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 29, 2026
@Mamaduka

Copy link
Copy Markdown
Member

Can we revert individual fixes like #85904 once this is merged?

@mirka

mirka commented Oct 30, 2026

Copy link
Copy Markdown
Member Author

Can we revert individual fixes like #85904 once this is merged?

I'm afraid not, those are still a custom case.

@mirka
mirka marked this pull request as ready for review November 3, 2026 15:36
@mirka
mirka requested a review from a team as a code owner November 3, 2026 15:36
# Conflicts:
#	packages/ui/CHANGELOG.md
@aduth

aduth commented Nov 4, 2026

Copy link
Copy Markdown
Member

This is marked for backport as fixing a bug, but the testing instructions apply to Storybook and I didn't observe any change in styles for the style variation buttons as shown in the sidebar screenshot. Is there a way to demonstrate the fix in the app?

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

I verified that there was previously no discernible difference when toggling aria-pressed for a neutral, minimal button under forced colors, and that with these changes the state change is more clear when either pressed or pressed and disabled.

@mirka mirka removed the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Nov 4, 2026
@mirka

mirka commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

This is marked for backport as fixing a bug, but the testing instructions apply to Storybook and I didn't observe any change in styles for the style variation buttons as shown in the sidebar screenshot. Is there a way to demonstrate the fix in the app?

🫪

Looks like I need to fix that ad hoc. I'll remove the backport label for this one (it doesn't fix any live issue on its own), and do a separate fix for that. Thanks for catching.

# Conflicts:
#	packages/ui/CHANGELOG.md
@mirka
mirka enabled auto-merge (squash) November 5, 2026 12:13
@mirka
mirka merged commit febd347 into trunk Nov 5, 2026
82 checks passed
@mirka
mirka deleted the fix/ui-button-forced-colors-pressed branch November 5, 2026 12:30
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] UI /packages/ui [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants