Skip to content

fix(Popover, HoverCard): surfaces paint the theme's text color, not the browser's CanvasText - #11451

Draft
nynexman4464 wants to merge 1 commit into
mainfrom
nynexman4464/fix/overlay-surface-text-color
Draft

nynexman4464 wants to merge 1 commit into
mainfrom
nynexman4464/fix/overlay-surface-text-color

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Text inside a Popover or HoverCard that inherits its color, such as a plain label or a bare text node, renders in the browser's CanvasText instead of the theme's primary text color.

  • In every theme this is pure black or pure white.
  • Where dark mode is applied without color-scheme, it renders black on the dark surface.

#12095 fixed the same defect for Dialog, Drawer, BottomSheet and MobileNav. Popover and HoverCard surfaces still lack it.

Problem and solution fit

The browser's stylesheet gives [popover] color: CanvasText. The Popover surface (usePopover) and the HoverCard container set a theme background but no color, so the browser's color beats the color inherited from Theme. Each now paints color: --color-text-primary beside its background, as #12095 does for the dialog surfaces.

Expected behavior and authority

Smallest restoration

One color declaration on each of the two surface styles.

  • A Popover with hasSurface={false} still leaves color to the caller.
  • Tooltip and Toast keep their inverted colors.

Evidence

  • Before (real Chromium 149, butter theme, plain label): Popover and HoverCard text was rgb(255,255,255) in dark against theme text rgb(243,242,226), and rgb(0,0,0) in light against rgb(29,28,17).
  • After: both match the theme text in both modes.
  • Regression tests: "paints the theme's text color on its surface, not the browser's" in the Popover and HoverCard suites fail without the change and pass with it. The Dialog and Drawer suites gain the same test, pinning fix(core): dialog text reads the theme, and toast text reaches AA on its card #12095 in jsdom.
  • Unchanged paths: the Dialog, Drawer, Popover, HoverCard and Tooltip suites pass (24 files, 639 tests).

Scope

Components: Popover, HoverCard

  • 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

  • pnpm exec vitest run --project ui packages/core/src/{Dialog,Drawer,Popover,HoverCard,Tooltip}: 24 files, 639 tests passed
  • Real browser: Chromium 149, butter and stone themes, light and dark, before and after (measured on the original head; the Popover and HoverCard lines are unchanged by the rebase)

@vercel

vercel Bot commented Nov 13, 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 Nov 16, 2026 7:39pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 13, 2026
@astracat-bot

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 16, 2026, 7:47 PM UTC

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

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

Thanks for tracking this down: plain text in these overlays does take the browser's black or white CanvasText, which is unreadable under a dark-only theme in light mode.

Blocking

  • MobileNav declares the new color on its inner drawer (packages/core/src/MobileNav/MobileNav.tsx:184) instead of the <dialog> that receives style, className, xstyle and the mobile-nav theme target, so a text color set on MobileNav no longer reaches the drawer text; declaring it in styles.dialog keeps the fix and restores that, and a test for it would catch a repeat.

Owner decision

No current spec says which text color an overlay surface owns (AST-038 FR3 keeps color owners unchanged for its text baseline, and AST-038 excludes standardizing foregrounds inside a layer), so an engineering owner needs to settle whether these surfaces paint --color-text-primary or inherit, by naming or updating the governing spec or by commenting /approve-spec with the full head SHA. As an engineering owner, you can record that decision yourself.

  • Non-blocking: the title says "overlay surfaces", but ContextMenu, DropdownMenu submenus and the TopNav mega menu keep CanvasText, so naming the components would match the changeset; BottomSheet, MobileNav and the inline Dialog have no test for the new color.
Claims and files checked
  • Claim: the seven components paint the theme's primary text color on their surfaces. Verified: six style declarations, and AlertDialog renders Dialog (AlertDialog.tsx:242).
  • Claim: inherited-color text took CanvasText from <dialog> and [popover]. Verified in Chromium: rgb(0, 0, 0) in light mode and rgb(255, 255, 255) in dark mode at the base.
  • Claim: it rendered black on a dark surface where dark mode is applied without a matching color scheme. Verified with the Gothic theme in light mode: black on rgb(16, 19, 20).
  • Claim: a plain label, textarea and bare text node are affected. Verified; the textarea follows only with the Astryx reset stylesheet, which makes form controls inherit color.
  • Claim: Butter text goes from white to rgb(243, 242, 226) in dark mode and from black to rgb(29, 28, 17) in light mode. Verified on Dialog and Popover.
  • Claim: AST-038 FR3 makes the surface that owns the background own its text color. Not established: FR3 only keeps owners unchanged for the text baseline (owner decision above).
  • Claim: Tooltip, Toast and Lightbox keep their colors, and the text reset is unchanged. Verified: not touched, and their tests pass.
  • Claim: a Popover with hasSurface={false} leaves color to the caller. Verified (usePopover.tsx:681).
  • Claim: the four new tests fail without the fix and pass with it. Verified: all four fail on the base with rgb(0, 0, 0).
  • Claim: no new public API. Verified: the built API surface shows no changed row.
  • Claim: the listed suites pass. Partly re-run: the four changed suites and the BottomSheet, MobileNav, AlertDialog, Tooltip, Toast and Lightbox suites pass.
  • File .changeset/overlay-surface-text-color.md: clear.
  • File packages/core/src/BottomSheet/BottomSheetPanel.tsx: clear.
  • File packages/core/src/Dialog/Dialog.tsx: clear.
  • File packages/core/src/Dialog/Dialog.test.tsx: clear.
  • File packages/core/src/Drawer/Drawer.tsx: clear.
  • File packages/core/src/Drawer/Drawer.test.tsx: clear.
  • File packages/core/src/HoverCard/useHoverCard.tsx: clear.
  • File packages/core/src/HoverCard/HoverCard.test.tsx: clear.
  • File packages/core/src/MobileNav/MobileNav.tsx: blocking finding above.
  • File packages/core/src/Popover/usePopover.tsx: clear.
  • File packages/core/src/Popover/Popover.test.tsx: clear.

Automated review (maintainer link)

@nynexman4464
nynexman4464 force-pushed the nynexman4464/fix/overlay-surface-text-color branch from a639fe2 to 86c05d4 Compare November 16, 2026 19:24
@nynexman4464 nynexman4464 changed the title fix(core): overlay surfaces paint the theme's text color, not the browser's CanvasText fix(Popover, HoverCard): surfaces paint the theme's text color, not the browser's CanvasText Nov 16, 2026

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

Approval waits on one owner decision; there are no blocking code findings, and the earlier MobileNav point no longer applies because MobileNav left this pull request.

Owner decision

No current spec says which text color the Popover surface and the HoverCard card paint: component:Popover's Default surface row names only background, radius and elevation, component:HoverCard FR1 names only the body font, and spec:AST-038 FR3 only keeps color owners unchanged for its text baseline, while the dialog-family records (component:Dialog FR10, component:Drawer FR21, component:BottomSheet FR25, component:MobileNav FR15) cover those surfaces alone. An engineering owner settles it by adding or naming the governing clause for these two surfaces, or by commenting /approve-spec followed by the full head commit SHA, and as an engineering owner you can record that decision yourself.

Non-blocking

  • Miss: the new comment in usePopover.tsx and useHoverCard.tsx repeats the declaration and mentions <dialog>, which neither surface is; "The browser gives [popover] CanvasText, which follows the color scheme and not the theme." keeps only the reason.
  • Miss: usePopover.doc.mjs says hasSurface applies background, radius and shadow; once the color is decided it should name the text color too.
  • The description's "A Popover with hasSurface={false}" describes usePopover's option; Popover has no such prop.
Claims and files checked

Review mode: full; reason: rebase

  • Changeset: Popover and HoverCard paint the theme's primary text color on their surfaces. Verified: usePopover.tsx:99, useHoverCard.tsx:52, and the new tests.
  • Changeset and description: inherited text took the browser's CanvasText, pure black or white, and black on a dark surface without a dark color scheme. Verified in Chromium: black on the Gothic light surfaces, pure white under Butter dark.
  • Description: the same defect is already fixed for Dialog, Drawer, BottomSheet and MobileNav. Verified on the base branch.
  • Description: a no-surface popover leaves color to the caller. Verified for usePopover's hasSurface: false (usePopover.tsx:715); Popover has no such prop.
  • Description: Tooltip and Toast keep their inverted colors. Verified: their sources are untouched and the Tooltip suites pass.
  • Description: the new Popover and HoverCard tests fail without the change and pass with it, and the Dialog and Drawer tests pin the shipped color. Verified against the base source.
  • Description: the Dialog, Drawer, Popover, HoverCard and Tooltip suites pass, 24 files and 639 tests. Verified.
  • Description: Butter text values before and after. Dark mode verified (white to rgb(243, 242, 226)); light mode not re-measured.
  • Description: no new public API. Verified: the API comparison lists no rows.
  • .changeset/overlay-surface-text-color.md: clear.
  • packages/core/src/Dialog/Dialog.test.tsx: clear.
  • packages/core/src/Drawer/Drawer.test.tsx: clear.
  • packages/core/src/HoverCard/HoverCard.test.tsx: clear.
  • packages/core/src/HoverCard/useHoverCard.tsx: waits on the owner decision; non-blocking comment note.
  • packages/core/src/Popover/Popover.test.tsx: clear.
  • packages/core/src/Popover/usePopover.tsx: waits on the owner decision; non-blocking comment and docs notes.

Automated review (maintainer link)

Comment on lines +97 to +98
// The surface sets its own text color: a <dialog> or [popover] otherwise
// takes the browser's CanvasText, not the theme's text.

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.

Non-blocking: the first clause repeats the declaration below, and this surface is a div inside the [popover] layer, not a <dialog>. Keeping only the reason:

// The browser gives [popover] CanvasText, which follows the color scheme and not the theme.

Comment on lines +50 to +51
// The surface sets its own text color: a <dialog> or [popover] otherwise
// takes the browser's CanvasText, not the theme's text.

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.

Non-blocking: same as in usePopover.tsx; the card is the [popover] element itself, never a <dialog>:

// The browser gives [popover] CanvasText, which follows the color scheme and not the theme.

This branch was successfully deployed

1 active deployment
Preview — 86c05d4c Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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