Skip to content

fix(regression-test): pair the theme page surface with its text color - #2670

Closed
drakeaharper wants to merge 2 commits into
masterfrom
fix/regression-test-theme-foreground
Closed

fix(regression-test): pair the theme page surface with its text color#2670
drakeaharper wants to merge 2 commits into
masterfrom
fix/regression-test-theme-foreground

Conversation

@drakeaharper

@drakeaharper drakeaharper commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Authored with AI assistance.

Why

The Visual regression job has been failing on every open PR since 2026-07-27 — not just mine. PRs merged Jul 22–24 passed it; everything since fails. feat/ui-card, vitest_browser_convert and every other open branch report the same 13 color-contrast (serious) violations.

Commit 1 — pair the page surface with its text color

a1e26e3a9 started painting each page from the active theme's background.page, but never set a matching foreground:

const pageBackground = semantics?.color?.background?.page ?? 'transparent'
<html style={{ background: pageBackground }}>

Inherited text therefore stays at its default dark value while the surface goes near-black:

Theme background.page color.text.base
canvas #ffffff #273540
light #F2F4F5 #273540
dark #10141A #F2F4F5

Roughly 1.2:1 instead of the ~15:1 the paired token gives. 99746bfa5 then made the a11y check run across canvas + light + dark rather than canvas only, which turned it into a suite failure.

Fixed by setting color from text.base next to the background, on both <html> and <body> (the body needs it for the same capture: 'fullPage' reason the existing comment describes for the background).

Commit 2 — remove hardcoded colors from three demo pages

Page Was Ratio
custom-icons Tailwind text-gray-500 / text-gray-700 4.38 light / 1.79 dark
small-components Text color="inherit" inside a hardcoded #AA0000 span 2.38 dark
tooltip bare <input> with no color, inheriting light text on the UA's white background 1.13 dark

Result

a11y failures
master 13 — matches CI exactly
+ commit 1 6
+ commit 2 4

Verified locally against the full spec, and commit 1's 13 → 6 was independently confirmed by this PR's own CI run.

The remaining 4 are not harness bugs — they need your call

All four are InstUI components sitting on InstUI's own View background variants, using the idiomatic pattern your heading and progressbar pages use:

  • <span class="baseButton__children">primary-inverse</span> — inverse Button
  • <a class="view-link">jumps</a> — Link
  • View page alert / success / danger / warning variants with default text
  • inverse Text

Two distinct contrast pairs remain:

#ffffff on #f2f4f5 — 1.10  (x3)   white inverse text on the LIGHT theme's page surface
#1c222b on #2b7abc — 3.51  (x1)   dark text on brand blue, under the 4.5:1 AA floor

The 1.10:1 case looks like a genuine defect: View background="primary-inverse" appears not to resolve to a dark surface under the light theme while color="primary-inverse" still resolves to white, so the two stop agreeing. That would affect any consumer using inverse variants on the light theme, not just this suite. See the detailed comment.

I deliberately have not forced these green. The only way to do that from the harness is to override the text colors on your components inside the demos, which would hide the behaviour rather than fix it. I tried the non-invasive route first — passing style={{ background: ... }} to the wrapping View — and it's a no-op, since style isn't in View's allowedProps.

Happy to go either way: tell me the inverse tokens are working as intended and I'll adjust the demos to suit, or leave these red until the tokens are addressed.

Context

Found while chasing red CI on #2666 and #2667 (two unrelated 11.7.4 regression fixes). Both add zero violations of their own and are blocked behind this job.

Painting the page from `background.page` without also setting the theme's
own text color leaves inherited text at its default dark value. On the
dark theme's near-black surface (#10141A) that is a serious
color-contrast violation for every plain label on these pages and for any
component using `color="inherit"`.

Set `color` from `text.base` alongside the background, on both <html> and
<body>, so each theme is captured with a foreground that belongs to it.

This is why the Visual regression job has been failing on every branch
since 2026-07-27: a1e26e3 introduced the per-theme surface and
99746bf started running the a11y check across all three themes, so the
unpaired foreground began failing the suite.

Verified locally against the full spec: 13 failures before, 6 after.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-31 11:11 UTC

@github-actions

Copy link
Copy Markdown
Contributor

Visual regression report

⚠️ Changes detected.

Status Count
Unchanged 0
Changed 1
New 96
Removed 32

📊 View full report

Diff images (33)

alert.png — baseline no longer produced

avatar.png — baseline no longer produced

badge.png — baseline no longer produced

billboard.png — baseline no longer produced

breadcrumb.png — baseline no longer produced

button-and-derivatives.png — baseline no longer produced

byline.png — baseline no longer produced

calendar.png — baseline no longer produced

checkbox.png — baseline no longer produced

checkboxgroup.png — baseline no longer produced

colorpicker.png — baseline no longer produced

contextview.png — baseline no longer produced

custom-and-lucide-icons.png — baseline no longer produced

dateinput-dateinput2.png — baseline no longer produced

datetimeinput.png — baseline no longer produced

diff-demo.png — 6324 pixels differ

drilldown.png — baseline no longer produced

filedrop.png — baseline no longer produced

form-errors.png — baseline no longer produced

heading.png — baseline no longer produced

img.png — baseline no longer produced

link.png — baseline no longer produced

menu.png — baseline no longer produced

metric-pill-tag-timeselect-text.png — baseline no longer produced

options.png — baseline no longer produced

pagination.png — baseline no longer produced

progressbar.png — baseline no longer produced

select-simpleselect.png — baseline no longer produced

table.png — baseline no longer produced

tabs.png — baseline no longer produced

tooltip.png — baseline no longer produced

treebrowser.png — baseline no longer produced

view.png — baseline no longer produced

Baselines come from the visual-baselines branch. They refresh on every merge to master.

github-actions Bot pushed a commit that referenced this pull request Jul 30, 2026
@drakeaharper

Copy link
Copy Markdown
Collaborator Author

Authored with AI assistance.

Contrast data for the 6 remaining failures — two look like real defects, not demo mistakes

I pulled the actual axe colour pairs. They split cleanly, and I want the second group on record even though I'm about to adjust the demos so the suite goes green.

Demo-page hardcoded colours (my problem, fixing in this PR)

fg bg ratio where
#aa0000 #10141a 2.38 small-components wraps <Text color="inherit"> in <span style={{ color: '#AA0000' }}>
#6a7282 #f2f4f5 4.38 custom-icons uses Tailwind text-gray-500
#364153 #10141a 1.79 custom-icons uses Tailwind text-gray-700
#000000 #10141a 1.13 tooltip renders a bare <input> with no colour set

None of these are component bugs — color="inherit" in particular is behaving exactly as documented.

Possible genuine dark/light theme defects (your call)

1. Inverse text at 1.1:1 on the light theme — appears 3×

foreground #ffffff, background #f2f4f5, ratio 1.10

#f2f4f5 is the light theme's background.page. So white inverse text is landing on the light theme's page surface. The affected pages use the idiomatic pattern that your own heading and progressbar pages use:

<View background="primary-inverse" as="div" padding="small medium">
  <Button color="primary-inverse">primary-inverse</Button>
</View>

That reads as View background="primary-inverse" not resolving to a dark surface under the light theme, while color="primary-inverse" still resolves to white — so the two stop agreeing. 1.1:1 is effectively invisible text. If that's right it affects any consumer using inverse variants on the light theme, not just this suite.

2. Body text on brand blue at 3.51:1

foreground #1c222b, background #2b7abc, ratio 3.51

Below the 4.5:1 AA threshold for normal-size text.

Why I'm changing the demos anyway

We need CI green to land two unrelated regression fixes (#2666, #2667) that are blocked behind this job, so I'm adjusting the demo pages to pass. That will make these two items stop being visible in CI, which is exactly why I'm recording the numbers here. If you'd rather I revert the demo changes for the inverse and brand-blue cases and leave the suite red until the tokens are addressed, say so and I'll do that instead — happy either way.

Three demo pages hardcode colors that only work on a light surface, so
they fail contrast once the suite renders each theme on its own
background:

- custom-icons used Tailwind `text-gray-500` / `text-gray-700`, which are
  4.38:1 on the light surface and 1.79:1 on the dark one. Dropping the
  classes lets the labels inherit the theme's text color.
- small-components demonstrates `Text color="inherit"` inside a
  hardcoded `#AA0000` span, which is 2.38:1 on the dark surface. Giving
  that span an explicit white background keeps the demo's point while
  making its contrast deterministic.
- tooltip renders a bare `<input>` with no color, so it inherited the
  page's light text while keeping the user-agent's white background
  (1.13:1). Now sets both explicitly.

Takes the suite from 13 failures to 4. The remaining 4 are InstUI
components on View background variants and are not harness bugs - see the
PR discussion.
github-actions Bot pushed a commit that referenced this pull request Jul 30, 2026
@balzss

balzss commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

@drakeaharper thanks for the PR, this issue will be solved in #2669, so I'm closing yours in favor of that

@balzss balzss closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants