An open source design system that's fully customizable and agent ready
TypeScript
fix(selector): suppress on-field status icon for detached statusVariant (#4581)
Cindy Zhang8d646485bdd5
diff --git a/.changeset/fix-detached-selector-status-icon.md b/.changeset/fix-detached-selector-status-icon.mdnew file mode 100644index 0000000000..0fcfdf2c0d--- /dev/null+++ b/.changeset/fix-detached-selector-status-icon.md@@ -0,0 +1,6 @@+---+'@astryxdesign/core': patch+---++[fix] Selector and MultiSelector: with `statusVariant="detached"`, the on-field status icon is no longer shown inside the trigger. The detached message box already renders its own leading status icon, so the field keeps its chevron indicator instead of duplicating the glyph — matching the bordered inputs.+@cixzhangdiff --git a/packages/core/src/MultiSelector/MultiSelector.test.tsx b/packages/core/src/MultiSelector/MultiSelector.test.tsxindex 236c653fc4..4f90b97600 100644--- a/packages/core/src/MultiSelector/MultiSelector.test.tsx+++ b/packages/core/src/MultiSelector/MultiSelector.test.tsx@@ -1424,6 +1424,40 @@ describe('MultiSelector statusVariant forwarding', () => {'detached',);});++ it('keeps the on-field status icon for the attached variant', () => {+ const {container} = render(+ <MultiSelector+ label="Fruit"+ options={['Apple', 'Banana']}+ value={[]}+ onChange={() => {}}+ status={{type: 'error', message: 'Required'}}+ />,+ );+ // Attached: the status glyph replaces the chevron indicator on the field.+ expect(+ container.querySelector('.astryx-multi-selector-indicator-icon'),+ ).toBeNull();+ });++ it('suppresses the on-field status icon for the detached variant', () => {+ const {container} = render(+ <MultiSelector+ label="Fruit"+ options={['Apple', 'Banana']}+ value={[]}+ onChange={() => {}}+ status={{type: 'error', message: 'Required'}}+ statusVariant="detached"+ />,+ );+ // Detached: the message box below carries its own leading icon, so the+ // field keeps its chevron indicator rather than duplicating the glyph.+ expect(+ container.querySelector('.astryx-multi-selector-indicator-icon'),+ ).not.toBeNull();+ });});describe('MultiSelector clear icon theme target', () => {diff --git a/packages/core/src/MultiSelector/MultiSelector.tsx b/packages/core/src/MultiSelector/MultiSelector.tsxindex 992aca33d0..d6a1e430a9 100644--- a/packages/core/src/MultiSelector/MultiSelector.tsx+++ b/packages/core/src/MultiSelector/MultiSelector.tsx@@ -1313,6 +1313,10 @@ export function MultiSelector<T extends MultiSelectorOptionType>({return elements;}, [options, renderItem, sortedItems, searchQuery, hasSelectAll]);+ // The detached message box renders its own leading status icon, so the+ // on-field icon would duplicate it — keep the chevron indicator instead.+ const showStatusIcon = status != null && statusVariant !== 'detached';+const multiSelectorContent = (<><div@@ -1414,10 +1418,10 @@ export function MultiSelector<T extends MultiSelectorOptionType>({<span{...stylex.props(styles.triggerIcon,- !status && popover.isOpen && styles.triggerIconOpen,- status && styles.triggerIconStatus,+ !showStatusIcon && popover.isOpen && styles.triggerIconOpen,+ showStatusIcon && styles.triggerIconStatus,)}>- {status ? (+ {showStatusIcon ? (<Iconicon={STATUS_ICON_MAP[status.type]}size="sm"diff --git a/packages/core/src/Selector/Selector.test.tsx b/packages/core/src/Selector/Selector.test.tsxindex bf79ca839b..b14f246929 100644--- a/packages/core/src/Selector/Selector.test.tsx+++ b/packages/core/src/Selector/Selector.test.tsx@@ -1241,6 +1241,36 @@ describe('Selector statusVariant forwarding', () => {'detached',);});++ it('keeps the on-field status icon for the attached variant', () => {+ const {container} = render(+ <Selector+ label="Fruit"+ options={['Apple', 'Banana']}+ status={{type: 'error', message: 'Required'}}+ />,+ );+ // Attached: the status glyph replaces the chevron indicator on the field.+ expect(+ container.querySelector('.astryx-selector-indicator-icon'),+ ).toBeNull();+ });++ it('suppresses the on-field status icon for the detached variant', () => {+ const {container} = render(+ <Selector+ label="Fruit"+ options={['Apple', 'Banana']}+ status={{type: 'error', message: 'Required'}}+ statusVariant="detached"+ />,+ );+ // Detached: the message box below carries its own leading icon, so the+ // field keeps its chevron indicator rather than duplicating the glyph.+ expect(+ container.querySelector('.astryx-selector-indicator-icon'),+ ).not.toBeNull();+ });});describe('Selector clear icon theme target', () => {diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsxindex 8e3302e832..7a1d38cef2 100644--- a/packages/core/src/Selector/Selector.tsx+++ b/packages/core/src/Selector/Selector.tsx@@ -1032,6 +1032,10 @@ export function Selector<T extends SelectorOptionType>(return elements;}, [options, renderItem, hasSearch, searchQuery, filteredItems]);+ // The detached message box renders its own leading status icon, so the+ // on-field icon would duplicate it — keep the chevron indicator instead.+ const showStatusIcon = status != null && statusVariant !== 'detached';+const selectorContent = (<><div@@ -1132,10 +1136,10 @@ export function Selector<T extends SelectorOptionType>(<span{...stylex.props(styles.triggerIcon,- !status && popover.isOpen && styles.triggerIconOpen,- status && styles.triggerIconStatus,+ !showStatusIcon && popover.isOpen && styles.triggerIconOpen,+ showStatusIcon && styles.triggerIconStatus,)}>- {status ? (+ {showStatusIcon ? (<Iconicon={STATUS_ICON_MAP[status.type]}size="sm"