Repository navigation
feat(selector): add disabled-trigger and caret-wrapper theme targets - #4626
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 ComponentsMultiSelector (@astryxdesign/core) · View in Storybook
Selector (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
left a comment
There was a problem hiding this comment.
The theme targets themselves look good and additive, and the caret wrapper (selector-indicator / multi-selector-indicator) with state: popover.isOpen ? 'expanded' : 'collapsed' matches the existing convention exactly (same as DateInput / DateRangeInput / MultiSelector). Nice.
One convention fix before this lands: the disabled reflection uses the wrong key.
themeProps('selector', {
size,
status: status?.type ?? null,
state: isDisabled ? 'disabled' : null, // ← emits data-state="disabled"
})Across the codebase state: is reserved for the expanded/collapsed (open) meaning, and disabled is reflected under a disabled: key — e.g. Switch, SegmentedControlItem, TreeListItem, DropdownMenuRadioItem, CheckboxInput, RadioListItem, Slider all use:
disabled: isDisabled ? 'disabled' : null, // → data-disabled="disabled"Using state for disabled here overloads data-state with two different meanings and diverges from every other component. Please switch the root trigger to disabled: isDisabled ? 'disabled' : null (→ data-disabled) in both Selector.tsx and MultiSelector.tsx, update the .doc.mjs target docs + the themingTargets guard accordingly, and keep state solely for the caret's expanded/collapsed. That keeps the disabled hook consistent system-wide.
|
Note: don't hand-author a |
|
Good catch — fixed. Switched both |
cixzhang
left a comment
There was a problem hiding this comment.
The disable state looks good now. I see we have both indicator and indicator icon. The indicator target will affect other icons that can appear in the same target area while the indicator icon is only the Carey icon URLs. Curious if this is your expectations around what is getting targeted
cixzhang
left a comment
There was a problem hiding this comment.
This is good just needs a rebase.
a1342f0 to
f9a6dd0
Compare
f9a6dd0 to
423c70f
Compare
cixzhang
left a comment
There was a problem hiding this comment.
🟡 Maintainer judgment — approval stands; holding the merge on a rebase plus one open question about selector-indicator.
The disabled reflection is exactly right now — disabled: isDisabled ? 'disabled' : null on the existing selector / multi-selector target matches Switch, CheckboxInput, RadioListItem, Slider, SegmentedControlItem, TreeListItem and Calendar verbatim, and data-state stays reserved for the caret. Tests are real (positive, negative, and a generateThemeTestCSS reachability assertion per seam). Thanks for turning that around quickly.
Rebase (required, trivial). The branch is 11 commits behind and #4627 landed today, giving exactly one conflict: Selector.test.tsx. Both sides are pure appends at end-of-file, so the resolution is "keep both describe blocks" — I verified locally that both suites (179 tests) and the themingTargets guard pass after that. Selector.tsx and Selector.doc.mjs auto-merge.
Coming back to my 08-03 question, with a receipt. astryx-selector-indicator isn't the chevron wrapper — it's the trailing-affordance slot. Rendering <Selector status={{type: 'error'}} />:
<span class="astryx-selector-indicator collapsed …" data-state="collapsed">
<span class="astryx-icon sm error" …><svg …/></span>
</span>
No caret in it, no astryx-selector-indicator-icon child — and on open it still flips to expanded even though triggerIconOpen is gated on !showStatusIcon, so nothing rotates. A theme rule on this target also lands on the status icon and the status-tooltip button, and data-state doesn't describe what's rendered. The PR body and changeset both call it "the chevron wrapper," which is what a consumer will believe.
A design direction I'm working through, and I'd like your read on it. I'm converging on: a theming target is a paint seam — color, background, border, font, radius, shadow. Layout (display, position, flex/grid, spacing, size, transform) is the component's structural contract, and it's exactly what a DOM refactor is entitled to change. Layout can still be themeable, but through a declared var rather than a raw class target on an internal element — which is what the system already does with --tree-list-indent, --button-icon-only-aspect and --button-focus-offset.
selector-indicator sits right on that line. styles.triggerIcon has one paint property (color) and the glyph already reaches that via selector-indicator-icon; the target's entire stated purpose is cancelling a transform. So it and my 08-03 question are really the same question.
Options, and I don't think it's obvious which is right:
- Move the rotation onto the glyph.
Icontakesxstyleand composes it throughstylex.props, and the glyph already carriesselector-indicator-iconwith the sameexpanded/collapsedvalues — so the existing paint target would reach it and the new one isn't needed. It'd also convergeComplexSelector, which has the identical wrapper+rotation structure and no wrapper target. Would want a before/after screenshot to confirm the rotation reads identically. - A public var —
--selector-indicator-rotation, documented intheming.vars[], same shape as--button-icon-only-aspect. A bounded knob instead of an open layout seam. - Decide it once in the design. Selector, MultiSelector and ComplexSelector all rotate today — "does the caret rotate on open" may just be a system answer rather than a theme knob.
I lean (1), but you've been closer to this than I have — what do you think? Since the branch has to be re-pushed for the rebase anyway, I'd rather settle it now than ship a target we can't easily remove.
If the wrapper target does stay, it needs a description on both entries in Selector.doc.mjs / MultiSelector.doc.mjs — right now astryx-selector-indicator and astryx-selector-indicator-icon sit next to each other with identical states: ['state'] and no prose, and a theme author has no way to tell which is the slot and which is the caret. The changeset and PR body should stop calling it "the chevron wrapper" too.
Small stuff:
MultiSelector.test.tsx:1884— the test name saysdata-state="disabled"but assertsdata-disabled. Leftover from the rename.- MultiSelector has no "reflects
expandedwhen open" test; Selector does. 'disabled:disabled'(Selector.test.tsx:1677,MultiSelector.test.tsx:1919) works, but since.doc.mjsdeclares it understates:the canonical key is the baredisabled: { … }.'state:expanded'is correct as-is.
423c70f to
9c40bc1
Compare
| states: ['disabled'], | ||
| }, | ||
| {className: 'astryx-multi-selector-clear-icon'}, | ||
| {className: 'astryx-multi-selector-indicator', states: ['state']}, |
There was a problem hiding this comment.
Instead of a new target on an internal wrapper, could we try moving the rotation styles inside of selector onto the icon so it can be themeable from the existing target?
There was a problem hiding this comment.
Done — removed the wrapper target entirely. The rotation styles stay on the span (they're internal structure), and the existing selector-indicator-icon target on the Icon element is sufficient for themes to override the glyph's color/size/state. This PR now only adds data-disabled reflection on the trigger.
| }, | ||
| {className: 'astryx-selector-option'}, | ||
| {className: 'astryx-selector-clear-icon'}, | ||
| {className: 'astryx-selector-indicator', states: ['state']}, |
Add data-disabled reflection on the root trigger for both Selector and MultiSelector, matching Switch/CheckboxInput/RadioListItem convention. Removed the selector-indicator wrapper target per review — rotation styles are reachable through the existing selector-indicator-icon target directly.
9c40bc1 to
383eec8
Compare
What
Adds two additive theme targets to the searchable Selector / MultiSelector so consumers can style them via
defineThemeinstead of structural CSS:data-state="disabled"onselector/multi-selectorselector-indicator/multi-selector-indicator(new)expanded/collapsedstateWhy
The trigger's
themePropsexposed only{size, status}, so a theme couldn't key on the disabled state — the disabled flag lives on the inner button, which no slot reaches.The caret's
rotate(180deg)(open state) is applied to the chevron wrapper span, while the only existing slot (selector-indicator-icon) is on the child glyph. A child element cannot cancel a transform applied to its parent, so a theme that wants a static caret (no open-state rotation) had no reachable hook. The newselector-indicatortarget lands on the wrapper span itself, so a theme can do:Scope
Purely additive
themePropson existing elements. No new props, no exported-type changes, no behavior or a11y change — default appearance is identical (guarded by existing byte-identity tests plus new negative tests: nodata-statewhen enabled).Testing
defineThemecan override the caret rotation via the wrapper slot.themingTargetsguard passes (every renderedthemePropsclass is documented in.doc.mjs).