Skip to content

feat(core): expand ComplexSelector composition API - #4769

Merged
cixzhang merged 8 commits into
mainfrom
docs/complex-selector-examples-forward-port
Aug 16, 2026
Merged

cixzhang merged 8 commits into
mainfrom
docs/complex-selector-examples-forward-port

Conversation

@ernestt

@ernestt ernestt commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Expand ComplexSelector with controlled visibility, input/ghost trigger variants, optional leading icons, popup alignment, exact selector sizing, focus restoration, and light-dismiss protection.
  • Add Core Storybook and CLI examples for custom grids, deadline pickers, searchable trees, and controlled toolbar triggers.
  • Keep the change scoped to the generic Core/CLI composition API.

The TransferList Lab package and its Storybook examples were separated into #4870 so they can land independently without Core review. This PR no longer contains any TransferList files.

API ownership

These APIs belong to the generic ComplexSelector shell rather than a specific selector composition:

  • controlled and uncontrolled open state share one popup lifecycle
  • trigger presentation is independent from popup content
  • popup alignment belongs to the selector shell
  • sm, md, and lg use exact 28px, 32px, and 36px trigger heights
  • render state exposes open/busy state and stable trigger/content IDs for custom surfaces

Documentation and examples

  • custom grid showcase
  • deadline picker
  • searchable tree
  • controlled toolbar trigger
  • updated component docs, tests, exports, Storybook, and changesets

Validation

  • focused ComplexSelector tests pass
  • Core TypeScript and documentation typechecks pass
  • Core production build passes
  • ESLint and Prettier pass
  • repository sync, package-boundary, changeset, demo-media, executable-bit, and CLI-structure checks pass

@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 14, 2026 2:07am

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 the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Aug 7, 2026
@ernestt ernestt changed the title docs(cli): add ComplexSelector showcase and examples docs(core): add ComplexSelector examples and fix trigger sizing Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 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 448 -
Complexity N/A Very High (44) -

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 7, 2026
@ernestt ernestt changed the title docs(core): add ComplexSelector examples and fix trigger sizing feat(core): expand ComplexSelector composition API and examples Aug 7, 2026
github-actions Bot added a commit that referenced this pull request Aug 7, 2026
@ernestt
ernestt force-pushed the docs/complex-selector-examples-forward-port branch from ecde9b3 to 596b3ec Compare August 8, 2026 01:22
github-actions Bot added a commit that referenced this pull request Aug 8, 2026
github-actions Bot added a commit that referenced this pull request Aug 9, 2026
github-actions Bot added a commit that referenced this pull request Aug 10, 2026
@ernestt
ernestt enabled auto-merge (squash) August 10, 2026 17:10
@ernestt ernestt changed the title feat(core): expand ComplexSelector composition API and examples feat: add TransferListSelector and expand ComplexSelector composition Aug 10, 2026
@ernestt
ernestt disabled auto-merge August 10, 2026 17:14
github-actions Bot added a commit that referenced this pull request Aug 10, 2026
@ernestt
ernestt force-pushed the docs/complex-selector-examples-forward-port branch from 2ec9460 to eab9ce1 Compare August 10, 2026 19:32
@ernestt ernestt changed the title feat: add TransferListSelector and expand ComplexSelector composition feat(core): expand ComplexSelector composition API Aug 10, 2026
Comment on lines +269 to +272
/** Whether the selector surface is open. Omit for uncontrolled behavior. */
isOpen?: boolean;
/** Called when the selector surface requests an open-state change. */
onOpenChange?: (isOpen: boolean) => void;

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.

The rest of the new props seem okay but I'm worried about controlled open via props. First starters it adds a lot of useEffects below which are all smells, but moreover I find that these tend to result in bad behaviors. We originally had them in Selector to handle showing the popover contents in the docsite which is a really niche use case. I've since gotten rid of it because it was causing issues with focus management. I suspect that we will encounter the same type of issues here.

Instead of isOpen and onOpenChange as props, perhaps we should consider a handleRef and allow for imperative controls on the selector instead. Those controls should be performed as part of a callback rather than as stateful updates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — dropped isOpen/onOpenChange entirely. Those brought in exactly the useEffect sync you flagged, and it's the same shape that caused the focus-management trouble in Selector.

Replaced them with an imperative handleRef (ComplexSelectorHandle → open() / close() / toggle() / isOpen()), matching the pattern Carousel and PowerSearch already use. The selector now solely owns its visibility, so focus restoration and light dismiss stay intact, and there's no external-state round-trip through an effect. The controls run imperatively rather than as stateful updates, as suggested.

Updated the toolbar example to drive the selector through the handle instead of mirroring open state, and refreshed the docs/tests/changeset. Pushed in 8b07cfd.

@github-actions
github-actions Bot requested a review from cixzhang August 10, 2026 23:42
github-actions Bot added a commit that referenced this pull request Aug 10, 2026
Adds the docsite showcase and example blocks for ComplexSelector, which
currently has an empty showcase slot and no Examples section on the
component page. These blocks previously landed on the component's feature
branch but were never merged to main because the branch had already been
merged, so they were stranded.

Three blocks, all composing existing components/primitives with semantic
tokens and StyleX only:

- Showcase: a two-axis fruit + ripeness grid, showing ComplexSelector
  owning the field/trigger/popover/focus-restore while custom grid content
  owns its own keyboard semantics (roving tabindex, role="grid").
- Deadline Picker: preset RadioList with a custom DateInput/TimeInput path
  and an explicit Apply action, for a multi-step flow that stays open until
  the user commits.
- Tree Search: TextInput search over a TreeList hierarchy that closes the
  popup on selection.

Also adds the showcase SYNC reference to ComplexSelector.tsx.
…perative handleRef

Drop isOpen/onOpenChange and the useEffect that synced external open state
into the popover. Expose a ComplexSelectorHandle (open/close/toggle/isOpen)
via handleRef instead, matching the imperative pattern used by Carousel and
PowerSearch. The selector owns its own visibility, so focus restoration and
light dismiss stay intact and there is no external-state/effect round-trip.
@ernestt
ernestt force-pushed the docs/complex-selector-examples-forward-port branch from 8b07cfd to c9ed7ba Compare August 12, 2026 09:17
github-actions Bot added a commit that referenced this pull request Aug 12, 2026
…olve

# Conflicts:
#	packages/core/src/ComplexSelector/ComplexSelector.tsx
Adopt offset render-prop from main (replacing CSS margin) while
preserving the alignment prop exposed by this PR.
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.

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

Thanks this is good. Will likely merge as is then do the nits separately

className,
style,
)}>
{startIcon &&

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.

Might need isRenderable check

Comment on lines +470 to +472
variant === 'input' && focusOutlineStyles.focusWithin,
variant === 'ghost' && styles.triggerGhost,
variant === 'ghost' && focusOutlineStyles.focusWithin,

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.

Hmm some of this seems redundant. Probably can apply the focus outline without a variant check


const isOpen = popover.isOpen;

const handleTriggerClick = useCallback(() => {

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.

I need to double check this with other recent updates to fix this across the board for menus

@cixzhang
cixzhang enabled auto-merge (squash) August 16, 2026 15:51
@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 16, 2026
@cixzhang
cixzhang merged commit 01592f7 into main Aug 16, 2026
21 checks passed
cixzhang added a commit that referenced this pull request Aug 17, 2026
…#5114)

Follow-up nits from the #4769 review:

- Both variant branches applied focusOutlineStyles.focusWithin, so the
  condition was always true; apply it unconditionally and restore the
  note explaining why the ring is :has(:focus-visible).
- Guard the start icon with isRenderable, the shared slot-content check.
@github-actions
github-actions Bot deleted the docs/complex-selector-examples-forward-port branch August 17, 2026 06:14

This branch was successfully deployed

1 active deployment
Preview — 136e3464 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants