Skip to content

Components: a dark dialog owns its surfaces, not just its text - #622

Open
AllTerrainDeveloper wants to merge 1 commit into
trunkfrom
os-modal-dark-surface-tokens
Open

Components: a dark dialog owns its surfaces, not just its text#622
AllTerrainDeveloper wants to merge 1 commit into
trunkfrom
os-modal-dark-surface-tokens

Conversation

@AllTerrainDeveloper

@AllTerrainDeveloper AllTerrainDeveloper commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

The bug

Mio's shape picker renders unthemed inside its style panel: a white <os-select> trigger with near-white text on it.

<os-modal> renders a dark dialog whatever the palette says, so it re-points the tokens its content reads on its own :host. It re-pointed the foreground--os-ui-fg, --os-ui-fg-muted, --os-ui-border — plus --os-window-bg for popovers and inputs. It did not re-point --os-ui-surface, which is what <os-select> paints its trigger from.

Token Palette Legacy Re-pointed?
--os-ui-fg #fffbff #1d2327 ✅ → #f0f0f1
--os-ui-surface #1a1721 #fff stays white
--os-ui-hover light wash rgba(0,0,0,.04) ❌ black-on-dark

This was invisible for as long as the palette outside the dialog was dark too — every token left behind happened to agree, and the dialog looked right. Under a light palette the halves come apart: the trigger goes white while the re-pointed --os-ui-fg writes #f0f0f1 onto it, and the hover wash is black over a dark row.

Pre-existing, not from the Legacy sweep--os-ui-surface has been #fff in the snapshot since it was collected. #620 made enough of the panel correct for the one wrong control to stand out.

The fix

Foreground and surface are a pair. The escape hatch now covers both — --os-ui-surface, --os-ui-surface-elevated, --os-ui-border-strong and --os-ui-hover join the set, each reading a palette-owned --os-ui-modal-* name so a desktop theme keeps the last word.

The four new palette names are literals, so Legacy answers them (463 tokens), per the rule #620 established.

Guard

A dark-context opt-out has to be closed. The reachability test now asserts the fg/surface pairs are re-pointed together, rather than trusting the next person to notice the second half:

--os-ui-fg        ↔ --os-ui-surface
--os-ui-fg-muted  ↔ --os-ui-surface-elevated
--os-ui-border    ↔ --os-ui-border-strong

plus --os-ui-hover, which belongs to the surface it darkens.

Docs

The copy-paste recipe in components-reference.md was the same incomplete list, so it was teaching the bug to anyone slotting components into their own dark surface. It carries all nine tokens now, grouped foreground / surface / wash, with the note that the short version looks correct until a light theme is worn. desktop-themes.md gets the same correction on the <os-modal> exception.

Testing

PHPUnit 2214 passed (Legacy class: 20 tests, 5660 assertions) · lint:php clean · vitest 4479 passed (reachability: 60) · typecheck clean · npm run build clean.

Manual QA

Wear Legacy, open Mio → style panel. The Shape select should read as a dark control on the dark dialog — dark trigger, light label — and hovering its options should show a visible wash. Same check applies to any <os-modal> with form controls in it.

🤖 Generated with Claude Code

Open WordPress Playground Preview

Mio's shape picker rendered unthemed inside its style panel: a white
<os-select> trigger with near-white text on it.

<os-modal> renders a dark dialog whatever the palette says, so it
re-points the tokens its content reads on its own :host. It re-pointed
the foreground — --os-ui-fg, --os-ui-fg-muted, --os-ui-border — and
--os-window-bg for popovers and inputs, but not --os-ui-surface, which
is what <os-select> paints its trigger from.

That was invisible for as long as the palette outside the dialog was
dark too: every token left behind happened to agree. Under a LIGHT
palette the halves come apart. Legacy sets --os-ui-surface to #fff, so
the trigger went white while the re-pointed --os-ui-fg wrote #f0f0f1
onto it. --os-ui-hover was rgba(0,0,0,0.04) over a dark row, which is
no hover at all.

Foreground and surface are a pair. The escape hatch now covers both:
--os-ui-surface, --os-ui-surface-elevated, --os-ui-border-strong and
--os-ui-hover join the set, each reading a palette-owned
--os-ui-modal-* name so a theme keeps the last word.

Pre-existing — not from the Legacy sweep, --os-ui-surface has been
#fff in the snapshot since it was collected. The sweep made enough of
the panel correct for the one wrong control to stand out.

Guard: a dark-context opt-out has to be closed, so the reachability
test now asserts the fg/surface pairs are re-pointed together rather
than trusting the next person to notice the second half.

Docs: the copy-paste recipe in components-reference.md was the same
list, so it taught the bug. It carries all nine tokens now, grouped
foreground / surface / wash, with the reason the incomplete version
looks correct until a light theme is worn.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant