Repository navigation
feat(core): expand ComplexSelector composition API - #4769
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsComplexSelector (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
ecde9b3 to
596b3ec
Compare
2ec9460 to
eab9ce1
Compare
| /** 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
8b07cfd to
c9ed7ba
Compare
…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
left a comment
There was a problem hiding this comment.
Thanks this is good. Will likely merge as is then do the nits separately
| className, | ||
| style, | ||
| )}> | ||
| {startIcon && |
There was a problem hiding this comment.
Might need isRenderable check
| variant === 'input' && focusOutlineStyles.focusWithin, | ||
| variant === 'ghost' && styles.triggerGhost, | ||
| variant === 'ghost' && focusOutlineStyles.focusWithin, |
There was a problem hiding this comment.
Hmm some of this seems redundant. Probably can apply the focus outline without a variant check
|
|
||
| const isOpen = popover.isOpen; | ||
|
|
||
| const handleTriggerClick = useCallback(() => { |
There was a problem hiding this comment.
I need to double check this with other recent updates to fix this across the board for menus
…#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.
Summary
ComplexSelectorwith controlled visibility, input/ghost trigger variants, optional leading icons, popup alignment, exact selector sizing, focus restoration, and light-dismiss protection.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
ComplexSelectorshell rather than a specific selector composition:sm,md, andlguse exact 28px, 32px, and 36px trigger heightsDocumentation and examples
Validation