Skip to content

feat(selector): themeable empty-state target on Selector and MultiSelector - #4756

Merged
cixzhang merged 1 commit into
mainfrom
feat/selector-dropdown-theme-target
Aug 7, 2026
Merged

cixzhang merged 1 commit into
mainfrom
feat/selector-dropdown-theme-target

Conversation

@freddymeta

@freddymeta freddymeta commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

What

Exposes the Selector / MultiSelector empty state ("No results found") as a stable theming target:

  • astryx-selector-empty-state
  • astryx-multi-selector-empty-state
.astryx-selector-empty-state {
  padding: 24px;
  font-size: 13px;
  color: var(--my-muted-text);
}

Why

Consumers currently have to style the empty state through fragile structural CSS selectors — e.g. matching "the only role-less child of the listbox" — because no stable class exists on it. That kind of selector is brittle (it can match unrelated role-less children in a consumer's own lists) and breaks silently when the internal DOM changes. A stable paint target replaces it with a supported seam.

The empty-state element paints (color, size, padding) and is a leaf, so it's a legitimate paint target — not a layout-only container.

Scope notes

  • Border: the trigger's border is already reachable via the existing astryx-selector root target, so no new target is needed for it. The dropdown surface border/background/shadow come from shared popover chrome (usePopover), not a Selector-owned element, so it's intentionally out of scope here.

  • Search placeholder: the search field is a TextInput, so its placeholder is already reachable via .astryx-text-input (the <input> is a child of that class). No redundant Selector-scoped target is added. A dedicated Selector-scoped placeholder seam would require a TextInput change and is left as a possible follow-up.

  • Non-breaking: purely additive — a stable class on an existing element. No API or visual change.

Changes

  • Selector.tsx / MultiSelector.tsx: stamp themeProps('selector-empty-state') / themeProps('multi-selector-empty-state') on the empty-state element.
  • *.doc.mjs: document the new classes in each theming.targets.
  • Tests for both components asserting the target renders on the empty state.

Verification

  • pnpm -F @astryxdesign/core build ✓
  • Selector + MultiSelector + theme suites: 778 tests pass ✓ (incl. themingTargets.test.ts — every rendered class is documented)
  • tsc --noEmit ✓, ESLint clean, check-sync ✓, check:changesets ✓

@vercel

vercel Bot commented Aug 6, 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 7, 2026 1:45pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 6, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Aug 6, 2026
@freddymeta freddymeta changed the title feat(selector): expose the dropdown listbox as a theme target feat(selector): expose dropdown theme targets on Selector and MultiSelector Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 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

MultiSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1451 -
Complexity N/A Very High (177) -
Selector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1441 -
Complexity N/A Very High (138) -

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

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

This PR makes an existing structural difference part of the public theming API:

<!-- Selector: search stays fixed -->
<div>search</div>
<div class="astryx-selector-dropdown" role="listbox">...</div>

<!-- MultiSelector: search scrolls with options -->
<div class="astryx-multi-selector-dropdown">
  search
  <div role="listbox">...</div>
</div>

Since styles.dropdown owns maxHeight and overflowY, these targets behave differently despite sharing the dropdown name.

Could we align them in this PR by exposing *-dropdown on the wrapper and *-listbox on the scrollable options?

If that behavioral change is out of scope, I would name the current targets by their actual scope: astryx-selector-listbox and astryx-multi-selector-dropdown.

visualProps: ['variant', 'size', 'status'],
},
{className: 'astryx-multi-selector-clear-icon'},
{className: 'astryx-multi-selector-dropdown'},

@cixzhang cixzhang Aug 6, 2026 •

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.

This probably needs a better name. like astryx-multi-selector-menu-popover? But this is starting to feel a bit like a reach for theming since we can have multiple containers here that compose.

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

🔴 Blocking — the entire stated use case here is layout (max-height, padding), which points at the derived-var pipeline rather than a class target; and the same target name lands on two structurally different elements. Plus needs:code-review on new public theming API.

Triage: new API surface (theming targets are a public commitment) · non-breaking · blast radius = two core components + the system-wide target vocabulary → deep path. ⚠️ Needs maintainer judgment on the API surface — per .github/instructions/packages.instructions.md, whether these targets should exist and take this shape is a human call.

Thanks for picking this up — the mechanics are clean (mergeProps order, no hand-authored data-*, no state sub-targets, docs guard satisfied, well-formed changeset). Two design concerns below are directions we're still working through rather than written wiki rules — flagging them as such — but together they say this wants a different mechanism.

🔴 1. This is a layout seam, and layout shouldn't be a class target

A theming target is best understood as a paint seam: color, background, border, radius, shadow, font. Layout — display, position, flex/grid, margin, padding, gap, width/max-height, transform — is the component's structural contract. It's what guarantees overflow behavior, focus order, hit-target size and RTL, and it's exactly what we need to stay free to change in a DOM refactor. Exposing it as a raw class target on an internal element freezes the structure and makes those guarantees theme-dependent.

Classifying this PR:

Target What the description themes
astryx-selector-dropdown max-height: 240px, padding: 4px layout
astryx-multi-selector-dropdown max-height: 240px, padding: 4px layout

And the styles behind the seam (Selector.tsx:237-249, MultiSelector.tsx:260-265) are boxSizing / maxHeight / overflowY / padding — no paint properties at all. Concretely: a theme setting max-height here is changing whether and where the option list scrolls, and in MultiSelector the same box decides whether the search field scrolls out of view with the options.

Layout is themeable today — deliberately — but through the declared derived-var pipeline, where the component still owns the structure and the theme only sets a value the component declared. DropdownMenu is the model, one component over, for exactly these two properties:

// DropdownMenu.doc.mjs
vars: [
  {name: '--_dropdown-menu-radius',  private: true, ...},
  {name: '--_dropdown-menu-padding', private: true, ...},
],
derived: [
  {property: 'borderRadius', vars: ['--_dropdown-menu-radius']},
  {property: 'padding',      vars: ['--_dropdown-menu-padding']},
],

so a theme writes dropdown-menu: {base: {padding: '8px'}} and DropdownMenu.tsx:73-76 decides where it lands. Selector and MultiSelector declare no theming.vars / derived at all today — that's the actual gap. If the need is dropdown padding / max-height, I'd rather we fill it that way (declared var + derived entry + derivedVarRegistry.ts) than with a class target on an internal div.

🔴 2. If a class target does survive: name it by position, and attach it to the component

Also emerging direction: when the thing being themed is composed inside a parent, the target should attach to that element/component instance (never a wrapper minted to hold it) and be named compositionally — {parent}-{position}-{thing}, where position says where it sits (trigger, option, row, header, menu) and the last segment says what it is (icon, checkbox, popover). We already name that way: tree-list-item-label, table-header-cell, breadcrumb-item-menu-trigger.

-dropdown has no position segment, and that vagueness is doing real damage here:

  • Selector.tsx:1310-1315 / 1323-1331 → the target lands on the scrolling role="listbox".
  • MultiSelector.tsx:1587-1591 → it lands on the wrapper that also contains renderSearch(); the inner listbox (:1592-1598) carries no styles.

Same name, two shapes, so one theme rule gives two results — padding: 4px insets only the options in Selector but also the search box in MultiSelector. That's Theming Infrastructure → principle #3 ("one name and shape per concept, across components"), and typeahead-dropdown (BaseTypeahead.tsx:808, identical styles.dropdown) already fixes {component}-dropdown = the scrolling option list, so Selector matches the sibling and MultiSelector diverges.

Names that state position would separate the two concepts cleanly — e.g. …-menu-popover for the surface vs …-option-list for the scroll box. Building on @imdreamrunner's point, though, I'd settle the design question first (principle 7, consolidate at the design level): should MultiSelector's search scroll away with the options when Selector's stays pinned? Fix that and the naming falls out.

🔴 3. The MultiSelector placement also trips the written rule

The head rule for themeProps says targets belong on "visible elements that have base styles," explicitly not on "structural wrappers (display: contents, layout containers)." MultiSelector.tsx:1587-1591 is a layout container that paints nothing — this one holds independently of #1 and #2.

🔴 4. No stated use case

The Why is "the container had no stable hook." Principle 6 rules that out explicitly: "Structural selectors are brittle, so here's a seam" is not sufficient justification — a target needs a stated visual intent from a real consumer need, because speculative targets are very hard to remove once shipped. Which theme wants this, and what should it look like?

🟡 5. The element that actually paints has no target — and it's a composed component

Three nested boxes here: the popover surface from usePopover.tsx:411-419 (styles.surface — background, radius, --shadow-low), the search wrapper, and the scroll box. The surface is the one that paints, and it carries no theme class at all (usePopover's render never calls themeProps, though Popover itself documents astryx-popover). So selector-dropdown: {base: {borderRadius, boxShadow}} would put paint on the inner scroll box and leave the visible edge unchanged. This is exactly the case #2 is about: if there's a real need, it's likely a compositional target on the surface instance (selector-menu-popover) for paint, plus declared vars for the layout — not a class on this div.

🟡 6. Tests don't exercise the claim

Selector.test.tsx:1321-1345 and MultiSelector.test.tsx:1512-1531 assert only that a class string exists in the closed/hidden DOM. Neither opens the dropdown, and neither runs defineTheme + generateThemeTestCSS — which is what proves a theme can reach it (see the sibling target tests in #4627/#4626/#4628). The MultiSelector assertion uses .closest(...), which passes if the class is on any ancestor, so it can't distinguish wrapper from listbox — exactly the distinction under discussion.

🟡 7. Changeset / description inaccuracies

  • .changeset/selector-dropdown-theme-target.md:5 calls both "the popover's option-list container" — not true of the MultiSelector element, which also wraps the search box.
  • The Why says both components already document an options target; MultiSelector has none on main (MultiSelector.doc.mjs:22-32) — that's the still-open #4628.

🟡 8. Portaled target with no visualProps

The dropdown renders into the popover layer, outside the .astryx-selector subtree, so the root's variant/size/status never reach it, and neither doc entry (Selector.doc.mjs:29, MultiSelector.doc.mjs:28) declares any — a theme can't express "dropdown for a small selector" (principle 2). typeahead-dropdown has the same gap; let's decide once and converge.

🟢 Nits

  • Doc entry placement differs between the files (Selector.doc.mjs:29 after -option; MultiSelector.doc.mjs:28 after -clear-icon) — pick one ordering.
  • Branch is behind main (#4627 landed on the same Selector.doc.mjs array afterwards) — rebase before landing.

Cross-PR note

This is the fourth concurrent PR adding theming targets to Selector/MultiSelector (#4626 indicator wrappers + disabled state, #4627 selector-check — merged, #4628 rows/select-all), and both concerns above run through the cluster:

  • Layout-as-target: #4626 themes transform on a wrapper; #4628 themes transform: scale() on a checkbox and display: none on a divider (principle 5 also bars a target whose purpose is hiding an internal element); this PR themes max-height/padding. #4628's -option / -option-label are properly paint.
  • Attach-to-the-component: #4627 got this right (the class goes on the Icon instance), #4628's -option-checkbox goes on a wrapper by its own test's description.

Structurally, #4628 + this PR would leave MultiSelector with rows and a wrapper but no name for the listbox, while Selector's -dropdown is the listbox. Given principle 7, I think these want to be one consolidated pass over Selector / MultiSelector / Typeahead / DropdownMenu that settles the vocabulary, the paint-vs-layout line, and the attachment rule together — driven by named consumer needs, rather than four PRs each freezing a different slice of internal structure into the public API. Happy to help scope that if you're up for it.

@freddymeta
freddymeta force-pushed the feat/selector-dropdown-theme-target branch from 9dff78e to 48c14c1 Compare August 7, 2026 13:41
@freddymeta freddymeta changed the title feat(selector): expose dropdown theme targets on Selector and MultiSelector feat(selector): themeable empty-state target on Selector and MultiSelector Aug 7, 2026
github-actions Bot added a commit that referenced this pull request Aug 7, 2026
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Aug 7, 2026
@cixzhang

cixzhang commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Thanks, accepted since it looks like feedback was resolved.

@cixzhang
cixzhang merged commit d52d2cb into main Aug 7, 2026
21 checks passed
@github-actions
github-actions Bot deleted the feat/selector-dropdown-theme-target branch August 8, 2026 06:25

This branch was successfully deployed

1 active deployment
Preview — 48c14c10 Deployed Aug 7, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants