Skip to content

fix(Code): inherited inline code in a MediaTheme surface takes the chip's own text color - #14307

Open
cixzhang wants to merge 6 commits into
mainfrom
fix/code-inherit-in-media-surface
Open

cixzhang wants to merge 6 commits into
mainfrom
fix/code-inherit-in-media-surface

Conversation

@cixzhang

@cixzhang cixzhang commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Stack: this PR, then #12410 on top.

User impact

People reading inline code that takes the surrounding text color (<Code color="inherit">) inside a MediaTheme surface, such as a Toast, can read it in every theme. Tooltip content, which paints the same inverted surface without a MediaTheme, is covered by #12410. Today, in Gothic, that code draws the surface's dark text on the page's dark chip (about 1.3:1). With this change it takes the chip's own text color, as default inline code already does.

Problem and solution fit

  • A media surface does not restyle the inline code chip: its colors come from the theme's own code rules in the surface's color scheme, and themes that restate their text colors on the chip (Butter, Gothic, Y2K) keep that text.
  • color="inherit" takes the text color of its parent, which is the surface's color, so it can land on a chip of the opposite brightness.
  • Inside a media surface, inherited code now takes the chip's own primary text color (--color-text-primary as the chip resolves it), whatever its parent's color is. So inherited code inside secondary text or a Link on a media surface also takes primary text, in every theme.

Expected behavior and authority

  • component:Code FR2 (amended) and DEC-1: a media surface does not restyle the chip, so there color="inherit" takes the chip's primary text, whatever the surrounding color (owner decision, 2026-12-03). The record's behavior, builder-impact, compatibility, AV3 and inherited-color rows name the change.
  • component:MediaTheme Owns: the internal marker its element carries for this.

Smallest restoration

Evidence

  • Reproduction before the change: CodeInMediaSurface.a11y.chromium.spec.ts at the test commit (eb5209c) fails in Gothic: the color="inherit" chip is 1.27:1 in light and dark; the other seven settings pass.
  • Result after the change: the same spec passes in all eight settings. Chip text against its own fill, both chips equal: Gothic 12.83:1 (light and dark), Butter 12.16 / 15.17, Y2K 13.65 / 12.38. Toast's and the theme's Chromium specs pass (96/96).
  • Representative unchanged path: <Code color="inherit"> outside a media surface still takes the surrounding color (the Colors story's play check compares it with its parent).
  • Regression test: CodeInMediaSurface.a11y.chromium.spec.ts over a plain media surface and a Toast (every shipped theme and Core's base tokens, light and dark).

Scope

Components: Code, MediaTheme

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run Code and MediaTheme: 204 passed.
  • Size (pnpm size:pages --base <merge base> --page toast=Toast --page code=Code, gzip): docs, form, menu and table +0; Toast +49 B; Code +6 B.

Real Chrome stills

Branded Chrome on macOS, the Core/Code InMediaSurface story. In Gothic, the inherited chip (pnpm test) goes from dark text on the dark chip to the chip's own light text. In Butter and Y2K light, its text moves from the surface's white to the chip's own near-white, matching the default chip. The other cells are pixel-identical.

Theme, mode Before (test commit eb5209c) After (this fix)
gothic, light before: gothic light after: gothic light
gothic, dark before: gothic dark after: gothic dark
butter, light before: butter light after: butter light
butter, dark before: butter dark after: butter dark
y2k, light before: y2k light after: y2k light
y2k, dark before: y2k dark after: y2k dark
neutral, light before: neutral light after: neutral light
neutral, dark before: neutral dark after: neutral dark
chocolate, light before: chocolate light after: chocolate light
chocolate, dark before: chocolate dark after: chocolate dark
matcha, light before: matcha light after: matcha light
matcha, dark before: matcha dark after: matcha dark
stone, light before: stone light after: stone light
stone, dark before: stone dark after: stone dark

Writing rubric results

Covers component:Code (FR2, its verification row, the behavior, builder-impact, compatibility, AV3 and inherited-color rows, and DEC-1) and component:MediaTheme's Owns bullet for the marker.

  • R1 narration: none; each line states what the chip or the marker does.
  • R2 research in the record: none; the contrast numbers stay in this description.
  • R3 evidence naming a change: none; the verification row names the spec file, not a pull request.
  • R4 rejected alternatives: none.
  • R5 pull request or issue references: none.
  • R6 ruled open questions still listing options: none.
  • R7 project status: none; present tense.

Overlap checked: #12410 (Tooltip content colors, which builds on this), #14302 (MediaTheme's internal fixed-mode surface; the marker moves with MediaTheme's element there).

Owner: @cixzhang

@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Dec 4, 2026 10:20am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 4, 2026
@astracat-bot

astracat-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Dec 4, 2026, 11:23 AM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Dec 4, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 1695029

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 0d35d58

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
lab/Comments 384.3 kB (+62 B) · 2.5 kB CSS (0) — — · — · —
Overlay 25.3 kB (+30 B) · 4.3 kB CSS (+27 B) — — · — · —
Toast 111.3 kB (+28 B) · 11.7 kB CSS (+29 B) — — · — · —

✓ passed · ✗ needs a fix · Δ changed, for review in the shots below · ↻ needs re-verify · — did not run

6 more components
Component Size LoC Visual · A11y · RTL
Lightbox 156.0 kB (+23 B) · 12.6 kB CSS (+31 B) — — · — · —
lab/CommentThread 377.3 kB (+51 B) · 2.4 kB CSS (0) — — · — · —
lab/DialogHeroHeader 96.2 kB (+46 B) · 372 B CSS (0) — — · — · —
Markdown 202.6 kB (+14 B) · 24.0 kB CSS (+24 B) — — · — · —
Code · Storybook 3.9 kB (+7 B) · 3.6 kB CSS (+30 B) 87 (+5) — · ✓ · —
lab/VideoPlayer 240.1 kB (+11 B) · 2.1 kB CSS (0) — — · — · —

Package size: @astryxdesign/core 8.18 MB packed (+943 B); no new dependencies.

Wide change (shared styles: packages/core/src/theme/MediaTheme.tsx, packages/core/src/theme/mediaSurface.stylex.ts): add ci:run-visual for Visual, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec b74008f

@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec c556ddd

@astracat-bot astracat-bot Bot 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.

Changes requested. The fix itself holds up: inside a media surface, inherited inline code now takes the chip's own primary text, and the Gothic chip goes from 1.27:1 to 12.83:1 in light and dark, in a plain media surface and in a Toast, reproduced in Chromium against both revisions during this review. Two of the pull request's own claims do not hold at this head, and one of them is the release note consumers will read.

  • Release note and title promise every inverted surface; inline code in a Tooltip is unchanged. The rule keys on a media surface, and a Tooltip paints the same inverted surface without one, so <Code color="inherit"> there still measures 1.27:1 in Gothic dark and 1.13:1 in Neutral light at this head; bound the title, the changeset line and the User impact paragraph to a media surface (MediaTheme), since #12410 is what covers Tooltip.
  • Inherited code inside secondary text or a Link changes in every theme, against the description's claim. "In themes that do not restate text on the chip, that is the same as the surrounding text" holds only for a primary parent: in Neutral, inherited code inside secondary text moves from rgb(158,158,158) to rgb(255,255,255) in light and rgb(71,71,71) to rgb(17,17,17) in dark, and inside a Link to primary; say instead that inherited code on a media surface takes primary text whatever its parent's color is.
  • Consumer docs still say inherit takes the surrounding text color. Code.doc.mjs describes the prop as taking the surrounding color in two places, which is now false inside a media surface, and Code.tsx's own SYNC header lists that file; non-blocking, but a one-line amendment keeps the published docs honest.
Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • Inherited inline code on an inverted surface, such as in a Toast, reads in every theme — false: a Tooltip's inverted panel is one, and its chip measures 1.27:1 in Gothic dark and 1.13:1 in Neutral light at this head.
  • In Gothic today that chip is about 1.3:1 — verified: 1.27:1 on the base, light and dark.
  • Inline code keeps the page's chip inside a media surface, and Butter, Gothic and Y2K restate their text colors on it — verified: those three themes carry the own-fill rule for the code part and the other four do not.
  • color="inherit" takes its parent's color, so it can land on a chip of the opposite brightness — verified on the base.
  • Inside a media surface inherited code takes the chip's own primary text; in themes that do not restate text on the chip, that is the same as the surrounding text — the second half is false for a secondary-text or Link parent, measured in Neutral light and dark.
  • component:Code FR2 amended and component:MediaTheme owns the internal marker — verified against both records at this head.
  • A class only, with no new attribute or DOM — verified: the compiled rule adds one declaration, and the repository's API generator reports no surface change in Core or the seven themes.
  • The marker moves with MediaTheme's element when the fixed-mode surface change lands, and the Toast case fails if it is missed — holds for the case it names.
  • <Code color="inherit"> outside a media surface still takes the surrounding color — verified in Chromium at this head; the unit tests cited for it assert the reflected color attribute, not the painted color.
  • Reproduction and after-contrast figures from the spec run (Gothic 12.83:1, Butter 12.16 / 15.17, Y2K 13.65 / 12.38), the 96/96 Chromium runs, the 204-test unit run and the page-size figures — reported; the Gothic figures reproduced here, and a wider unit run passed here.
  • Branded Chrome stills to follow — pending author evidence, not required by an applicable claim.

Files:

  • .changeset/code-inherit-in-media-surface.md — finding: the release note repeats the over-broad claim.
  • apps/storybook/stories/Code.stories.tsx — clear: two stories that give the contrast spec its fixtures.
  • docs/specs/components/Code/Code.spec.md — clear: FR2 amendment and the verification row, owner-approved for this spec text.
  • docs/specs/components/theme/MediaTheme.spec.md — clear: the marker is named in the ownership boundary.
  • packages/core/src/Code/Code.tsx — clear as code; the behavior it adds is what the first two findings mis-describe.
  • packages/core/src/Code/__tests__/CodeInMediaSurface.a11y.chromium.spec.ts — clear: eight theme settings, light and dark, over the plain surface and the Toast.
  • packages/core/src/theme/MediaTheme.tsx — clear: the marker rides the existing element, and off still renders no surface.
  • packages/core/src/theme/mediaSurface.stylex.ts — clear: internal marker module, named by the approved record change.

Automated review (maintainer link)

Comment thread packages/core/src/Code/Code.tsx Resolved
@cixzhang cixzhang changed the title fix(Code): inherited inline code on an inverted surface takes the chip's own text color fix(Code): inherited inline code in a MediaTheme surface takes the chip's own text color Dec 4, 2026
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 6862eac

@astracat-bot astracat-bot Bot 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.

Changes requested. The fix works: inside a media surface, inherited inline code now takes the chip's own primary text, and Gothic's chip goes from 1.27:1 to 12.83:1 (reproduced locally: the new contrast spec passes all 16 cases on this branch and fails only the two Gothic cases against the base). The earlier points about the release note's scope, inherited code under a non-primary parent and the color docs are fixed. What remains is wording in the release note, the docs and the Code record:

  • Inline code takes the surface's chip, not the page's, in every theme but Gothic. The release note, the color prop docs, the amended FR2 and the comments in Code.tsx, the story and the spec header say inline code "keeps the page's chip" on a media surface, but measured in Chromium the chip there follows the surface's color scheme in Butter, Chocolate, Matcha, Neutral, Stone, Y2K and Core's base tokens (on a Neutral light page it goes from rgb(241,241,241) with black text to rgb(27,27,27) with white text), so say instead that the surface does not restyle the chip, whose colors come from the theme's own code rules in the surface's color scheme.
  • Code's record still says inherited code follows the surrounding color and changes nothing. Code.spec.md keeps the inherited-color representative state, AV3, the at-a-glance behavior, builder-impact and compatibility rows, the compatibility class and "None recorded" in the decision log beside the amended FR2, so give the state row and AV3 the media-surface exception, name the color change in the impact and compatibility lines, and log the 2026-12-03 decision.
Claims and files checked

Review mode: incremental; reason: none

changed rules (0): none

Claims:

  • Inherited inline code inside a MediaTheme surface, such as a Toast, reads in every theme — verified: the contrast spec passes in all seven shipped themes and the base tokens, light and dark, on a plain surface and in a Toast (run locally).
  • Tooltip content is left to the follow-up pull request — verified: Tooltip renders no MediaTheme, so this change does not reach it.
  • In Gothic today the inherited chip is about 1.3:1 — verified: 1.27:1 against the base, light and dark.
  • Inherited code now takes the chip's own text color, as default code does — verified: both chips measure the same color on this branch in every setting.
  • Inline code keeps the page's chip inside a media surface — false: the chip follows the surface's color scheme in every theme but Gothic.
  • Butter, Gothic and Y2K restate their text colors on the chip — verified from the built theme CSS; the other four shipped themes do not.
  • Inherited code took the surface's color, so it could land on a chip of the opposite brightness — verified against the base in Gothic.
  • Inherited code takes primary text whatever its parent's color is, in every theme — verified: with its parent forced to red, it keeps the chip's primary text in all 16 settings.
  • The amended Code FR2 and the MediaTheme ownership bullet govern the change — verified, and approved for this head.
  • The marker is a class only, with no new attribute or DOM — verified: one hashed class, and the API report generator lists no change in Core or any theme.
  • The color docs say what inherit takes on a media surface — verified in both doc entries; the wording repeats the false "page's chip" claim.
  • The inherit color is conditional on a media-surface ancestor that carries the marker — verified in the source and the compiled CSS.
  • The Toast case fails if the marker is missed — verified: against the base, the Toast case fails in Gothic.
  • Inherited code outside a media surface still takes the surrounding color — verified in Chromium on both revisions; the cited unit tests check the reflected attribute, not the painted color.
  • The contrast spec covers a plain surface and a Toast in every shipped theme and the base tokens, light and dark — verified.
  • No new public API, default or interaction model under the fix label, and no internal context in public text — verified.
  • Red-first run at the test commit, after-fix contrast figures, 96/96 related Chromium specs, the 204-test unit run, the page-size figures and the Chrome stills — reported; the contrast figures, the stills' changed and unchanged cells, a 95-test related Chromium run and a 669-test unit run reproduce locally.

Files:

  • .changeset/code-inherit-in-media-surface.md — finding: repeats the "page's chip" claim.
  • apps/storybook/stories/Code.stories.tsx — finding: the story comment repeats the claim; the two stories are sound fixtures.
  • docs/specs/components/Code/Code.spec.md — findings: FR2 states the "page's chip" claim, and other lines of the record contradict FR2.
  • docs/specs/components/theme/MediaTheme.spec.md — clear.
  • packages/core/src/Code/Code.doc.mjs — finding: the color description repeats the claim.
  • packages/core/src/Code/Code.tsx — finding: the comment repeats the claim; the rule itself is correct.
  • packages/core/src/Code/__tests__/CodeInMediaSurface.a11y.chromium.spec.ts — finding: the header repeats the claim; the checks are sound.
  • packages/core/src/theme/MediaTheme.tsx — clear.
  • packages/core/src/theme/mediaSurface.stylex.ts — clear.

Automated review (maintainer link)

Comment thread packages/core/src/Code/Code.doc.mjs Resolved
Comment thread docs/specs/components/Code/Code.spec.md Resolved
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 0d35d58

@astracat-bot astracat-bot Bot 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.

Approved pending CI: CI has not run on this head yet, so its required checks still need to pass before merge.

Inside a MediaTheme surface, inherited inline code now takes the chip's own primary text; the new Chromium spec passed in every theme setting on this commit and failed only Gothic at 1.27:1 on the base, both reproduced locally. The amended Code and MediaTheme records are approved for this commit, and the description's revised evidence line now points at the Colors play check that asserts the unchanged path. Nothing blocks.

Claims and files checked

Review mode: same-head; reason: none

  • Title, inherited code in a MediaTheme surface takes the chip's own text color: verified (local Chromium probe on this commit, 16 theme settings and a Toast).
  • Release note, inherited code in a MediaTheme surface such as a Toast reads in every theme: verified (the new spec passed 16/16 locally on this commit; lowest inherited chip 8.49:1).
  • Release note, the surface does not restyle the chip, so inherited text takes the chip's primary whatever the surrounding color, where Gothic drew dark on dark: verified (secondary and Link parents take the chip's text in all 16 settings; base Gothic 1.27:1).
  • User impact, readable in every theme inside a MediaTheme surface: verified (as above).
  • User impact, Tooltip content is covered by the Tooltip pull request: verified (Tooltip renders no media surface; that pull request is open and builds on this one).
  • User impact, Gothic today draws about 1.3:1: verified (1.27:1 on the base, light and dark).
  • User impact, inherited code now matches default inline code: verified (inherited and default chips equal in every setting).
  • Problem, the surface does not restyle the chip and Butter, Gothic and Y2K restate the chip's text: verified (only those three theme sources restate the code part; no shipped theme has a media rule).
  • Problem, inherit takes the surface's color and can land on a chip of opposite brightness: verified (base Gothic).
  • Problem, inherited code takes the chip's primary text whatever the parent, secondary and Link included, in every theme: verified (local probe, 16 settings).
  • Authority, Code's amended FR2 and new decision, and the rows named: verified (record lines); approved for this commit.
  • Authority, MediaTheme owns the internal marker: verified (record Owns bullet).
  • Restoration, a new internal marker that is a class only, with no new attribute or DOM: verified (marker module, MediaTheme's props, no API change from the generator).
  • Restoration, Code's docs say what inherit takes on a media surface: verified (both doc strings).
  • Restoration, inherit takes primary text under the ancestor condition: verified (Code.tsx and the built CSS).
  • Restoration, merge order with the MediaTheme surface pull request and the Toast case fails if the marker is missed: Toast case verified (it fails in Gothic on the base locally); merge order reported (the other pull request states the same plan).
  • Evidence, the spec fails only Gothic at 1.27:1 before the change: verified (local red-first run).
  • Evidence, the spec passes in every setting after the change: verified (16/16 locally).
  • Evidence, chip ratios for Gothic, Butter and Y2K: verified (same numbers measured locally).
  • Evidence, Toast and theme Chromium specs pass 96/96: reported.
  • Evidence, inherited code outside a media surface still takes the surrounding color, per the Colors story's play check: verified (the play check asserts inherited equals its parent and passed locally).
  • Evidence, the regression spec covers a plain surface and a Toast in every shipped theme and base tokens, light and dark: verified (spec lists; every setting renders a media surface).
  • Scope, Code and MediaTheme, one defect, nothing hidden under the fix label, no internal context: verified (no API change; text scan clean).
  • Testing, vitest for Code and MediaTheme passes: reported (a wider local run: 847 passed).
  • Testing, size deltas on the reference pages, Toast and Code: reported.
  • Real Chrome stills, Gothic flips and Butter and Y2K light move to the chip's near-white: reported; consistent with local frames.
  • Writing rubric results, covering Code's FR2, verification row, behavior, builder-impact, compatibility, AV3 and inherited-color rows and the decision, and MediaTheme's Owns bullet: verified (each named part changed).
  • Writing rubric, no narration, research, change references, rejected alternatives, open questions with options, or project status: verified (every changed record line read; Code's open questions are none).
  • Overlap with the Tooltip and MediaTheme surface pull requests: verified (both open; their bodies describe the same order).
  • .changeset/code-inherit-in-media-surface.md: clear.
  • apps/storybook/stories/Code.stories.tsx: clear.
  • docs/specs/components/Code/Code.spec.md: clear.
  • docs/specs/components/theme/MediaTheme.spec.md: clear.
  • packages/core/src/Code/Code.doc.mjs: clear.
  • packages/core/src/Code/Code.tsx: clear.
  • packages/core/src/Code/__tests__/CodeInMediaSurface.a11y.chromium.spec.ts: clear.
  • packages/core/src/theme/MediaTheme.tsx: clear.
  • packages/core/src/theme/mediaSurface.stylex.ts: clear.

Automated review (maintainer link)

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Dec 4, 2026
@cixzhang
cixzhang marked this pull request as ready for review December 4, 2026 11:37

This branch was successfully deployed

1 active deployment
Preview — 0d35d587 Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant