Skip to content

fix(core): move the popup theme targets onto the surface that paints - #5009

Merged
cixzhang merged 2 commits into
mainfrom
selector-dropdown-target
Aug 14, 2026
Merged

cixzhang merged 2 commits into
mainfrom
selector-dropdown-target

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Why

You asked whether #4991's targets were consistent with Selector's. Checking that turned up something worse than a naming problem: the targets were on the wrong element.

Measured in Chromium, the ancestor chain of .astryx-complex-selector-popup as shipped in 0.4.0:

depth element background radius shadow padding
0 .astryx-complex-selector-popup rgba(0,0,0,0) 0px none 8px
1 role="dialog", no astryx class rgb(255,255,255) 12px set 0px
2 [popover] layer transparent 0 none 0

Depth 1 is the surface usePopover renders. That is the element painting the popup, and it had no theme target at all — so the class a theme reaches for to restyle a popup's background, border or elevation was attached to the padding box inside it, where none of those rules can paint the popup. The changelog promised exactly those four properties.

What

The targets move to the surface. Because the surface belongs to usePopover and not to the component, a component cannot put a class there on its own — so usePopover gains surfaceTarget, the name to stamp on it, and always stamps a shared astryx-popover-surface so a theme can style every popup surface at once.

Selector gains astryx-selector-popup, which MultiSelector had and it did not — the asymmetry that started this. Putting the target on the surface also dissolves the reason I skipped Selector in #4991: its popup root differs by the hasSearch branch, but the surface is the same element either way, so one theme rule now means one box instead of two.

Names unchanged, so no deprecation alias: -popup was the right word for this element all along. Anything styling padding through these classes in the few hours 0.4.0 has existed would need to move to the component's own content, which is why this is a [fix] rather than silent.

Risk

Low. No default visual change — the surface's own StyleX styles are untouched, and the classes only add a theming hook. The behavioral change is which element the class sits on, and it is hours old with no known consumer.

One trap worth flagging for review: mergeProps is positional, and a third object argument is read as style, not as more props. My first attempt passed stylex.props(...) third and silently lost every surface style — caught by re-measuring, not by types or tests. The call is now composed into two arguments. Worth a follow-up: a variadic mergeProps, or a dev warning, because that failure is invisible.

Testing

  • packages/core full suite: 6310 pass, 242 files. Typecheck clean. eslint clean on all four changed component dirs (the one borderVars warning in MultiSelector is pre-existing — 1 before, 1 after).
  • Four new assertions, one per component, that the class lands on the element carrying the dialog role and the shared surface class, with the component's content box inside it — the shape that was wrong before.
  • Selector's is parameterized over hasSearch, pinning that both branches resolve to the same element.
  • Non-vacuous: neutralizing surfaceTarget fails exactly 5 tests and nothing else; restoring passes 223.
  • Browser re-measure after the fix: the targeted element now reports rgb(255,255,255) / 12px / shadow set for both ComplexSelector and MultiSelector.

The targets added in #4991 landed on each component's content box, while
the element carrying background, radius and elevation is the surface
usePopover renders one level above it. A theme rule written against those
classes could not paint the popup.

usePopover now names the surface: a shared astryx-popover-surface on every
popup, plus an optional per-component surfaceTarget. Selector gains the
astryx-selector-popup its sibling MultiSelector already had.
@vercel

vercel Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 14, 2026 1:25am

Request Review

@cixzhang cixzhang added theming Theming system, design tokens, createTheme component New or improved UI component labels Aug 14, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 14, 2026
@cixzhang
cixzhang enabled auto-merge (squash) August 14, 2026 01:02
@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

ComplexSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 346 -
Complexity N/A Very High (31) -
MultiSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1439 -
Complexity N/A Very High (182) -
Popover (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 553 -
Complexity N/A Very High (52) -
Selector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1492 -
Complexity N/A Very High (155) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 14, 2026
The guard scans core for themeProps()/stableClassName()/legacyNames
literals. A surface target is a literal too — it just rides a
usePopover option, because the element it names is not the component's
to render.
@cixzhang
cixzhang requested a review from josephfarina as a code owner August 14, 2026 01:22
@cixzhang
cixzhang merged commit 41f53a0 into main Aug 14, 2026
19 checks passed
github-actions Bot added a commit that referenced this pull request Aug 14, 2026
ernestt added a commit that referenced this pull request Aug 14, 2026
Adopt surfaceTarget from #5009 which correctly places the theme target on
the popover surface element. Keep the handleRef composition API close
helper and handlePopoverHide callback. Use shared focusOutlineStyles for
ghost variant focus ring.
@github-actions
github-actions Bot deleted the selector-dropdown-target branch August 14, 2026 06:33

This branch was successfully deployed

1 active deployment
Preview — 4e567d0d Deployed Aug 14, 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. component New or improved UI component theming Theming system, design tokens, createTheme

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant