Repository navigation
fix(Popover, HoverCard): surfaces paint the theme's text color, not the browser's CanvasText - #11451
nynexman4464 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
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 receivesstyle,className,xstyleand themobile-navtheme target, so a text color set on MobileNav no longer reaches the drawer text; declaring it instyles.dialogkeeps 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
CanvasTextfrom<dialog>and[popover]. Verified in Chromium:rgb(0, 0, 0)in light mode andrgb(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 torgb(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.
…he browser's CanvasText
a639fe2 to
86c05d4
Compare
There was a problem hiding this comment.
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.tsxanduseHoverCard.tsxrepeats 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.mjssayshasSurfaceapplies background, radius and shadow; once the color is decided it should name the text color too. - The description's "A Popover with
hasSurface={false}" describesusePopover's option;Popoverhas 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'shasSurface: false(usePopover.tsx:715);Popoverhas 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.
| // The surface sets its own text color: a <dialog> or [popover] otherwise | ||
| // takes the browser's CanvasText, not the theme's text. |
There was a problem hiding this comment.
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.| // The surface sets its own text color: a <dialog> or [popover] otherwise | ||
| // takes the browser's CanvasText, not the theme's text. |
There was a problem hiding this comment.
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.
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
CanvasTextinstead of the theme's primary text color.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 nocolor, so the browser's color beats the color inherited fromTheme. Each now paintscolor: --color-text-primarybeside its background, as #12095 does for the dialog surfaces.Expected behavior and authority
spec:AST-038FR3: "Color/background pairs … MUST retain their existing owners". The surface that owns the background owns its text color.Smallest restoration
One
colordeclaration on each of the two surface styles.hasSurface={false}still leaves color to the caller.Evidence
rgb(255,255,255)in dark against theme textrgb(243,242,226), andrgb(0,0,0)in light againstrgb(29,28,17).Scope
Components: Popover, HoverCard
Testing
pnpm exec vitest run --project ui packages/core/src/{Dialog,Drawer,Popover,HoverCard,Tooltip}: 24 files, 639 tests passed