Skip to content

Theme: Fix legacy primary Button contrast under ThemeProvider - #86548

Closed
ciampo wants to merge 2 commits into
trunkfrom
codex/fix-legacy-primary-button-contrast
Closed

ciampo wants to merge 2 commits into
trunkfrom
codex/fix-legacy-primary-button-contrast

Conversation

@ciampo

@ciampo ciampo commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Related: #82506 and #85073 migrate Button colors directly to WPDS tokens. This is a smaller bridge fix that retains legacy accent overrides. #86310 changes admin color seeds; #86189 addresses contrast lost during color rounding.

What?

Fix legacy primary Button text contrast under ThemeProvider at rest, on hover, and while active.

Why?

With primary #916745 and background #1e1e1e, the styled Button uses black text against legacy fills with contrast of 4.23:1, 3.48:1, and 2.80:1. The bridge derives those fills from the original seed, while its semantic foreground is calculated for adjusted fills.

How?

Use the generated resting and active fills for the provider's legacy admin color variables and their RGB companions. Keep the existing Components aliases and consumer override path.

This changes the provider-scoped legacy accent palette for all consumers of those variables. Hover and active now share the semantic active fill, which can be lighter than the resting fill in a dark theme.

Testing Instructions

  1. Open Components / @wordpress-components / Actions / Button / Primary in local Storybook.
  2. In the Design System theme toolbar, choose a custom theme with primary #916745 and background #1e1e1e.
  3. Inspect the Button's computed text and background colors at rest and on hover. Their contrast must reach 4.5:1.
  4. Repeat with background #fcfcfc.
  5. On a wrapper inside the provider, override --wp-components-color-accent, --wp-components-color-accent-darker-10, --wp-components-color-accent-darker-20, and --wp-components-color-accent-inverted. Confirm the Button uses the overrides in each state.

Testing Instructions for Keyboard

Move the pointer away, Tab to the primary Button, and hold Space. Confirm the active text/background pair reaches 4.5:1 in both themes. Release Space and confirm activation still works.

Regression coverage and contrast results

The regression tests load the real Button stylesheet and ThemeProvider. The dark-theme case reproduces all three reported failures before the fix. The tests also cover the light theme, held-Space activation, and consumer accent overrides. All 104 affected tests pass in Chromium, along with the production build, scoped type checks, and JavaScript lint.

The bridge's generated pairs give these ratios for primary #916745:

Background Rest Hover Active
#1e1e1e 4.56:1 5.60:1 5.60:1
#fcfcfc 4.57:1 5.54:1 5.54:1

Screenshots or screencast

Isolated styled Button at rest with primary #916745 and background #1e1e1e. Matching 240 × 88 captures compare trunk fb727e5d367 with this change.

Before After
Primary Button before the bridge fix Primary Button after the bridge fix

Use of AI Tools

Codex investigated the cause, implemented the fix and tests, ran verification, captured the comparison, and drafted this description. A separate Codex agent reviewed the change.

@github-actions github-actions Bot added [Package] Components /packages/components [Package] Theme /packages/theme labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

📦 Bundle size

Size Change: -323 B (0%)

Total Size: 8.63 MB

📦 View Changed
Filename Size Change
build/scripts/theme/index.min.js 26.6 kB -323 B (-1.2%)

9cb2c21 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 59321c0 trunk % Change
timeToFirstByte 43.85 ms +6.5% -2.85% 45.1 ms +7.43% -4.88% -2.77%
largestContentfulPaint 76 ms +5.26% -5.26% 76 ms +2.63% -5.26% 0%
lcpMinusTtfb 30.9 ms +15.21% -9.55% 29.45 ms +2.72% -5.77% 4.92%
wpBeforeTemplate 22.81 ms +6.01% -2.15% 23.13 ms +7.52% -1.77% -1.38%
wpTemplate 17.36 ms +5.24% -3.63% 18.14 ms +3.97% -6.28% -4.3%
wpTotal 40.52 ms +6.19% -2.89% 41.69 ms +8.01% -5.33% -2.81%
wpMemoryUsage 7.72 MB +0% -0% 7.69 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 59321c0 trunk % Change
timeToFirstByte 36.95 ms +7.31% -3.65% 37.75 ms +6.09% -5.3% -2.12%
largestContentfulPaint 80 ms +5% -0% 80 ms +5% -0% 0%
lcpMinusTtfb 44.4 ms +1.91% -3.72% 44.3 ms +3.05% -2.6% 0.23%
wpBeforeTemplate 19.67 ms +9.56% -1.42% 20.22 ms +4.25% -2.97% -2.72%
wpTemplate 13.56 ms +5.83% -2.21% 14.26 ms +3.3% -6.31% -4.91%
wpTotal 34.02 ms +7.61% -3.12% 34.72 ms +6.39% -5.01% -2.02%
wpMemoryUsage 6.41 MB +0% -0% 6.38 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 59321c0 trunk % Change
mediaProcessingJpeg 330.76 ms +1.21% -0.22% 330.7 ms +0.93% -0.46% 0.02%
mediaProcessingAvif 4897.99 ms +0.17% -0.27% 4857.8 ms +0.77% -0.11% 0.83%
mediaProcessingJpegToAvif 3403.77 ms +0.33% -0.29% 3380.84 ms +0.38% -0.06% 0.68%

media-upload

Metric 59321c0 trunk % Change
jpegUploadProcessing 1459.47 ms +2.99% -2.71% 1434.83 ms +0.77% -0.55% 1.72%
pngUploadProcessing 226.53 ms +3.27% -2.53% 221.6 ms +7.87% -3.19% 2.22%
largeJpegUploadProcessing 1428.47 ms +0.88% -0.18% 1418.73 ms +0.74% -0.31% 0.69%
multipleImageUploadProcessing 1517.21 ms +0.64% -1.64% 1496.01 ms +8.09% -1.31% 1.42%

post-editor

Metric 59321c0 trunk % Change
serverResponse 273.62 ms +1.42% -7.95% 271.67 ms +3.71% -8.98% 0.72%
firstPaint 257.45 ms +37.08% -6.07% 254.42 ms +6.82% -9.52% 1.19%
domContentLoaded 609.22 ms +3.3% -2.91% 584.31 ms +0.7% -1.62% 4.26%
loaded 610.3 ms +3.29% -2.95% 585.26 ms +0.73% -1.62% 4.28%
firstContentfulPaint 356.47 ms +4.26% -1.9% 344.81 ms +3.1% -3% 3.38%
firstBlock 1560.71 ms +3.42% -1.2% 1522.07 ms +0.69% -1.38% 2.54%
type 13.2 ms +3.18% -10.83% 13.88 ms +5.91% -4.61% -4.9%
typeWithoutInspector 13.28 ms +4.97% -8.58% 13.34 ms +4.05% -7.65% -0.45%
typeWithTopToolbar 16.76 ms +4.36% -13.37% 16.67 ms +7.02% -7.5% 0.54%
typeContainer 6.77 ms +5.91% -14.92% 5.83 ms +5.66% -7.38% 16.12%
focus 77.78 ms +13.99% -3.52% 74.68 ms +3.35% -4.82% 4.15%
firstFocus 177.39 ms +0% -0% 144.67 ms +0% -0% 22.62%
selectAll 253.43 ms +4.61% -0.98% 237.4 ms +1.81% -2.46% 6.75%
undo 24.53 ms +5.63% -7.42% 22.15 ms +1.81% -8.67% 10.74%
listViewOpen 52.55 ms +5.98% -4.66% 47.78 ms +16.62% -14.17% 9.98%
inserterOpen 34.44 ms +12.72% -10.37% 27.21 ms +10.47% -13.34% 26.57%
inserterHover 9.75 ms +4.41% -6.77% 8.27 ms +7.26% -3.39% 17.9%
inserterSearch 7.47 ms +8.03% -4.28% 6.27 ms +1.44% -2.55% 19.14%
loadPatterns 496.94 ms +2.93% -4.61% 425.95 ms +2.37% -4.7% 16.67%
wpTotal 266.61 ms +1.48% -8.11% 264.8 ms +3.83% -9.09% 0.68%
wpMemoryUsage 14.77 MB +0% -0% 14.74 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 59321c0 trunk % Change
serverResponse 312.31 ms +0.73% -9.52% 313.16 ms +1.3% -7.32% -0.27%
firstPaint 277.32 ms +10.25% -8.3% 298.86 ms +9.98% -4.88% -7.21%
domContentLoaded 682.28 ms +5.04% -1.42% 693.25 ms +1.62% -2.26% -1.58%
loaded 683 ms +5.05% -1.43% 694.08 ms +1.63% -2.25% -1.6%
firstContentfulPaint 394.44 ms +6.35% -1.61% 400.5 ms +4.01% -2.48% -1.51%
firstBlock 2050.43 ms +1.83% -3.2% 2038.63 ms +0.5% -0.39% 0.58%
type 15.03 ms +4.46% -9.98% 14.66 ms +3.55% -4.71% 2.52%
navigate 86.24 ms +8.74% -3.43% 89.53 ms +6.43% -5.88% -3.67%
loadPatterns 1053.28 ms +10.44% -19.74% 975.21 ms +9.15% -6.31% 8.01%
loadPages 1009.58 ms +5.78% -5.76% 1026.77 ms +1.76% -4.06% -1.67%
wpTotal 304.04 ms +0.75% -9.75% 304.81 ms +1.29% -7.62% -0.25%
wpMemoryUsage 12.79 MB +0% -0% 12.75 MB +0% -0% 0.27%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

9cb2c21 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-182-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
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
Page List converts to Navigation Links with entity bindings in /test/e2e/specs/editor/blocks/navigation.spec.js, passed after 1 failed attempt.
Error: expect(locator).toContainText(expected) failed

Locator: getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
Expected substring: "test-page-1"
Received string:    "Link to:Cat/catPagePublished"
Timeout: 5000ms

Call log:
  - Expect "toContainText" getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ }) with timeout 5000ms
  - waiting for getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
    14 × locator resolved to <button type="button" aria-expanded="false" aria-haspopup="dialog" class="components-button link-preview-button is-next-40px-default-size is-secondary">…</button>
       - unexpected value "Link to:Cat/catPagePublished"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation.spec.js:1949:31
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": 1,
+   "offset": 1,
  }

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

9cb2c21 Run

@ciampo

ciampo commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #85073

@ciampo ciampo closed this Nov 9, 2026
@ciampo
ciampo deleted the codex/fix-legacy-primary-button-contrast branch November 9, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Package] Theme /packages/theme

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant