Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(selector): drop the shared trigger-icon wrapper (#4846)

Cindy Zhang8a9073af37c2
diff --git a/.changeset/selector-trigger-icon-consolidation.md b/.changeset/selector-trigger-icon-consolidation.md
new file mode 100644
index 0000000000..427030d704
--- /dev/null
+++ b/.changeset/selector-trigger-icon-consolidation.md
@@ -0,0 +1,9 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Drop the shared trigger-icon wrapper in Selector, MultiSelector and ComplexSelector — each trigger icon is now the element that carries its own box, colour and theme target.
+
+The wrapper set a 16px box and `--color-icon-secondary` on a span with no theme target of its own, shared by two different affordances: the status glyph and the disclosure chevron. `<Icon>` already provides both (`size="sm"` is the same 16px box, `color="secondary"` the same token), so the wrapper only stood between a theme and the icons — and made the two affordances share a node they never should have shared.
+
+@cixzhang
diff --git a/packages/core/src/ComplexSelector/ComplexSelector.tsx b/packages/core/src/ComplexSelector/ComplexSelector.tsx
index 0cf763e455..35da221f63 100644
--- a/packages/core/src/ComplexSelector/ComplexSelector.tsx
+++ b/packages/core/src/ComplexSelector/ComplexSelector.tsx
@@ -97,14 +97,11 @@ const styles = stylex.create({
placeholder: {
color: colorVars['--color-text-secondary'],
},
+ // Only what Icon does not already provide: `sm` gives the 16px box and
+ // `color="secondary"` the color, but the glyph still must not shrink inside
+ // the flex trigger.
triggerIcon: {
flexShrink: 0,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- width: 16,
- height: 16,
- color: colorVars['--color-icon-secondary'],
},
// Rotation lives on the chevron glyph itself (passed through `xstyle`), not
// on the layout wrapper above, so the icon's
@@ -381,23 +378,23 @@ export function ComplexSelector<Value>({
<span {...stylex.props(styles.triggerText)}>{triggerContent}</span>
</button>
{isBusy && <Spinner size="sm" />}
- <span {...stylex.props(styles.triggerIcon)}>
- <Icon
- icon="chevronDown"
- size="sm"
- color="inherit"
- // The rotation rides on the glyph rather than the wrapper span so
- // the theme target below reaches both the mark and its open/closed
- // transform.
- xstyle={[
- styles.triggerIconRotation,
- popover.isOpen && styles.triggerIconOpen,
- ]}
- {...themeProps('complex-selector-indicator-icon', {
- state: popover.isOpen ? 'expanded' : 'collapsed',
- })}
- />
- </span>
+ <Icon
+ icon="chevronDown"
+ size="sm"
+ color="secondary"
+ // No wrapper: Icon's own span already provides the 16px box (`sm`)
+ // and the secondary icon color the wrapper used to set, so the glyph
+ // IS the trigger's icon element — one node carrying the box, the
+ // color, the rotation, and the theme target.
+ xstyle={[
+ styles.triggerIcon,
+ styles.triggerIconRotation,
+ popover.isOpen && styles.triggerIconOpen,
+ ]}
+ {...themeProps('complex-selector-indicator-icon', {
+ state: popover.isOpen ? 'expanded' : 'collapsed',
+ })}
+ />
</div>
{popover.render(content, {
diff --git a/packages/core/src/MultiSelector/MultiSelector.test.tsx b/packages/core/src/MultiSelector/MultiSelector.test.tsx
index 8837b3ecdd..113add04d0 100644
--- a/packages/core/src/MultiSelector/MultiSelector.test.tsx
+++ b/packages/core/src/MultiSelector/MultiSelector.test.tsx
@@ -1694,9 +1694,12 @@ describe('MultiSelector indicator (chevron) icon theme target', () => {
});
});
- it('renders the default icon (inherit color, sm size) byte-identically', () => {
+ it('renders the default icon (secondary color, sm size) byte-identically', () => {
// Pixel-identical default guard: the chevron glyph must carry the exact
- // same StyleX color/size classes as a standalone inherit/sm icon. The added
+ // same StyleX color/size classes as a standalone secondary/sm icon. The
+ // glyph now sets --color-icon-secondary itself rather than inheriting it
+ // from a wrapper span that set the same token, so the rendered color is
+ // unchanged. The added
// target class + data-state are purely additive — they change nothing until
// a theme targets them.
const {container} = render(
@@ -1710,7 +1713,7 @@ describe('MultiSelector indicator (chevron) icon theme target', () => {
const icon = getIndicatorIcon(container);
const {container: refContainer} = render(
- <Icon icon="chevronDown" size="sm" color="inherit" />,
+ <Icon icon="chevronDown" size="sm" color="secondary" />,
);
const refIcon = refContainer.querySelector('.astryx-icon') as HTMLElement;
diff --git a/packages/core/src/MultiSelector/MultiSelector.tsx b/packages/core/src/MultiSelector/MultiSelector.tsx
index 17f6a9d06d..ed6484e4c9 100644
--- a/packages/core/src/MultiSelector/MultiSelector.tsx
+++ b/packages/core/src/MultiSelector/MultiSelector.tsx
@@ -158,14 +158,11 @@ const styles = stylex.create({
color: colorVars['--color-text-secondary'],
fontWeight: fontWeightVars['--font-weight-medium'],
},
+ // Only what Icon does not already provide: `size="sm"` gives the 16px box
+ // and `color` the token, but the glyph still must not shrink inside the flex
+ // trigger.
triggerIcon: {
flexShrink: 0,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- width: 16,
- height: 16,
- color: colorVars['--color-icon-secondary'],
},
// Rotation lives on the chevron glyph itself (passed through `xstyle`), not
// on the layout wrapper above, so the icon's `multi-selector-indicator-icon`
@@ -1545,8 +1542,13 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
/>
</button>
)}
- <span {...stylex.props(styles.triggerIcon)}>
- {showStatusIcon ? (
+ {/*
+ No wrapper span: Icon's own span already provides the 16px box (`sm`)
+ and the icon color, so the status glyph and the chevron are each
+ directly targetable instead of sharing one untargetable parent — and
+ the two affordances stop sharing a node.
+ */}
+ {showStatusIcon ? (
showStatusTooltip ? (
<button
ref={statusTooltip.ref}
@@ -1559,6 +1561,7 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
icon={STATUS_ICON_MAP[status.type]}
size="sm"
color={STATUS_ICON_COLOR_MAP[status.type]}
+ xstyle={styles.triggerIcon}
/>
</button>
) : (
@@ -1566,17 +1569,19 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
icon={STATUS_ICON_MAP[status.type]}
size="sm"
color={STATUS_ICON_COLOR_MAP[status.type]}
+ xstyle={styles.triggerIcon}
/>
)
) : (
<Icon
icon="chevronDown"
size="sm"
- color="inherit"
- // The rotation rides on the glyph rather than the wrapper span so
- // the theme target below reaches both the mark and its
- // open/closed transform.
+ color="secondary"
+ // The rotation rides on the glyph, alongside the box and color
+ // the wrapper used to provide, so one element carries the mark,
+ // its open/closed transform, and the theme target.
xstyle={[
+ styles.triggerIcon,
styles.triggerIconRotation,
popover.isOpen && styles.triggerIconOpen,
]}
@@ -1588,9 +1593,8 @@ export function MultiSelector<T extends MultiSelectorOptionType>({
{...themeProps('multi-selector-indicator-icon', {
state: popover.isOpen ? 'expanded' : 'collapsed',
})}
- />
- )}
- </span>
+ />
+ )}
</div>
{popover.render(
diff --git a/packages/core/src/Selector/Selector.test.tsx b/packages/core/src/Selector/Selector.test.tsx
index 0e53b9b5fd..b158869f4e 100644
--- a/packages/core/src/Selector/Selector.test.tsx
+++ b/packages/core/src/Selector/Selector.test.tsx
@@ -1628,9 +1628,12 @@ describe('Selector indicator (chevron) icon theme target', () => {
});
});
- it('renders the default icon (inherit color, sm size) byte-identically', () => {
+ it('renders the default icon (secondary color, sm size) byte-identically', () => {
// Pixel-identical default guard: the chevron glyph must carry the exact
- // same StyleX color/size classes as a standalone inherit/sm icon. The added
+ // same StyleX color/size classes as a standalone secondary/sm icon. The
+ // glyph now sets --color-icon-secondary itself rather than inheriting it
+ // from a wrapper span that set the same token, so the rendered color is
+ // unchanged. The added
// target class + data-state are purely additive — they change nothing until
// a theme targets them.
const {container} = render(
@@ -1639,7 +1642,7 @@ describe('Selector indicator (chevron) icon theme target', () => {
const icon = getIndicatorIcon(container);
const {container: refContainer} = render(
- <Icon icon="chevronDown" size="sm" color="inherit" />,
+ <Icon icon="chevronDown" size="sm" color="secondary" />,
);
const refIcon = refContainer.querySelector('.astryx-icon') as HTMLElement;
diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsx
index 97beaff2e4..405311c23d 100644
--- a/packages/core/src/Selector/Selector.tsx
+++ b/packages/core/src/Selector/Selector.tsx
@@ -135,14 +135,11 @@ const styles = stylex.create({
whiteSpace: 'nowrap',
textAlign: 'start',
},
+ // Only what Icon does not already provide: `size="sm"` gives the 16px box
+ // and `color` the token, but the glyph still must not shrink inside the flex
+ // trigger.
triggerIcon: {
flexShrink: 0,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- width: 16,
- height: 16,
- color: colorVars['--color-icon-secondary'],
},
// Rotation lives on the chevron glyph itself (passed through `xstyle`), not
// on the layout wrapper above, so the icon's `selector-indicator-icon` theme
@@ -1282,8 +1279,13 @@ export function Selector<T extends SelectorOptionType>(
/>
</button>
)}
- <span {...stylex.props(styles.triggerIcon)}>
- {showStatusIcon ? (
+ {/*
+ No wrapper span: Icon's own span already provides the 16px box (`sm`)
+ and the icon color, so the status glyph and the chevron are each
+ directly targetable instead of sharing one untargetable parent — and
+ the two affordances stop sharing a node.
+ */}
+ {showStatusIcon ? (
showStatusTooltip ? (
<button
ref={statusTooltip.ref}
@@ -1296,6 +1298,7 @@ export function Selector<T extends SelectorOptionType>(
icon={STATUS_ICON_MAP[status.type]}
size="sm"
color={STATUS_ICON_COLOR_MAP[status.type]}
+ xstyle={styles.triggerIcon}
/>
</button>
) : (
@@ -1303,17 +1306,19 @@ export function Selector<T extends SelectorOptionType>(
icon={STATUS_ICON_MAP[status.type]}
size="sm"
color={STATUS_ICON_COLOR_MAP[status.type]}
+ xstyle={styles.triggerIcon}
/>
)
) : (
<Icon
icon="chevronDown"
size="sm"
- color="inherit"
- // The rotation rides on the glyph rather than the wrapper span so
- // the theme target below reaches both the mark and its
- // open/closed transform.
+ color="secondary"
+ // The rotation rides on the glyph, alongside the box and color
+ // the wrapper used to provide, so one element carries the mark,
+ // its open/closed transform, and the theme target.
xstyle={[
+ styles.triggerIcon,
styles.triggerIconRotation,
popover.isOpen && styles.triggerIconOpen,
]}
@@ -1325,9 +1330,8 @@ export function Selector<T extends SelectorOptionType>(
{...themeProps('selector-indicator-icon', {
state: popover.isOpen ? 'expanded' : 'collapsed',
})}
- />
- )}
- </span>
+ />
+ )}
</div>
{popover.render(
diff --git a/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx b/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx
index 097d2e6a95..28c37600f9 100644
--- a/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx
+++ b/packages/core/src/Table/plugins/groupedRows/useTableGroupedRows.tsx
@@ -20,7 +20,6 @@ import {
fontWeightVars,
} from '../../../theme/tokens.stylex';
import {Icon} from '../../../Icon';
-import {themeProps} from '../../../utils/themeProps';
import type {TablePlugin} from '../../types';
import {useTranslator} from '../../../i18n';
diff --git a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
index 3a372c5021..da6a7eb82c 100644
--- a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
+++ b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
@@ -20,7 +20,6 @@ import * as stylex from '@stylexjs/stylex';
import {spacingVars, colorVars, radiusVars} from '../../../theme/tokens.stylex';
import {Icon} from '../../../Icon';
import {rtlStyles} from '../../../utils';
-import {themeProps} from '../../../utils/themeProps';
import {resolveContextActions} from '../../tableContextMenu';
import {useTranslator} from '../../../i18n';
import type {
diff --git a/packages/core/src/Table/plugins/tree/useTableTreeData.tsx b/packages/core/src/Table/plugins/tree/useTableTreeData.tsx
index 3cf50e030a..2cc3580b76 100644
--- a/packages/core/src/Table/plugins/tree/useTableTreeData.tsx
+++ b/packages/core/src/Table/plugins/tree/useTableTreeData.tsx
@@ -43,7 +43,6 @@ import * as stylex from '@stylexjs/stylex';
import {colorVars, radiusVars, spacingVars} from '../../../theme/tokens.stylex';
import {Icon} from '../../../Icon';
import {mergeRefs} from '../../../utils';
-import {themeProps} from '../../../utils/themeProps';
import type {
TablePlugin,
TableColumn,