An open source design system that's fully customizable and agent ready
TypeScript
fix(Selector): collapse empty mark column (#5619)
athz9cfb2b59a128
diff --git a/.changeset/selector-empty-mark-column.md b/.changeset/selector-empty-mark-column.mdnew file mode 100644index 0000000000..7d9f20b355--- /dev/null+++ b/.changeset/selector-empty-mark-column.md@@ -0,0 +1,9 @@+---+'@astryxdesign/core': patch+---++[fix] Selector: collapse an option's mark column when its resolved selection indicator renders nothing.++Unselected rows using the default check indicator no longer lose label width to an empty wrapper. Selected marks and themed indicators that render an unselected state keep their space at the configured logical edge.++@athzdiff --git a/apps/storybook/stories/Selector.stories.tsx b/apps/storybook/stories/Selector.stories.tsxindex 48029ebce1..ddcf292854 100644--- a/apps/storybook/stories/Selector.stories.tsx+++ b/apps/storybook/stories/Selector.stories.tsx@@ -1,6 +1,7 @@// Copyright (c) Meta Platforms, Inc. and affiliates.import type {Meta, StoryObj} from '@storybook/react';+import {expect, waitFor} from 'storybook/test';import {useState} from 'react';import {Button} from '@astryxdesign/core/Button';import {InputGroup} from '@astryxdesign/core/InputGroup';@@ -1094,12 +1095,12 @@ export const DefaultSelectionIndicator: Story = {};/**- * `indicatorPosition="start"` moves the mark to the leading edge, the way a- * native menu marks its chosen row.+ * `indicatorPosition="start"` moves a rendered mark to the leading edge, the+ * way a native menu marks its chosen row.*- * The column is reserved on every row, not just the chosen one, so the labels- * stay on one line — the default check draws nothing when unchecked, and- * without the column only the chosen label would be indented.+ * The default check draws nothing when unchecked, so its empty mark wrapper+ * collapses. Unselected labels gain that space; the selected label may shift or+ * have less available width while its visible mark remains at the logical start.*/export const StartIndicatorPosition: Story = {render: () => {@@ -1116,3 +1117,222 @@ export const StartIndicatorPosition: Story = {);},};++type IndicatorSpaceEvidenceConfig = {+ direction: 'ltr' | 'rtl';+ indicatorPosition: 'start' | 'end';+ name: string;+ presentation: 'popover' | 'bottom-sheet';+ usesRadioIndicator: boolean;+ width: '12rem' | '24rem';+};++const indicatorEvidenceOptions = [+ {+ value: 'selected',+ label: 'Selected option with a deliberately long readable label',+ },+ {+ value: 'unselected',+ label: 'Unselected option with a deliberately long readable label',+ },+];++function createIndicatorSpaceEvidenceStory(+ config: IndicatorSpaceEvidenceConfig,+): Story {+ const surfaceTarget =+ config.presentation === 'popover' ? 'selector-popup' : 'bottom-sheet';+ const theme = defineTheme({+ name: `selector-ast004-${config.name}`,+ components: {+ [surfaceTarget]: {+ base: {width: config.width, maxWidth: config.width},+ },+ },+ ...(config.usesRadioIndicator ? {indicators: {check: RadioIndicator}} : {}),+ });++ return {+ globals: {direction: config.direction},+ parameters: {+ docs: {+ description: {+ story:+ 'AST-004 evidence: the open selection surface keeps visible marks at the configured logical edge and gives empty marks no layout width.',+ },+ },+ },+ render: (_args, context) => (+ <Theme+ theme={theme}+ mode={context.globals.colorMode === 'dark' ? 'dark' : 'light'}>+ <div+ data-ast004-indicator-space={config.name}+ style={{width: config.width}}>+ <Selector+ label="Project with long option labels"+ options={indicatorEvidenceOptions}+ value="selected"+ onChange={() => {}}+ indicatorPosition={config.indicatorPosition}+ presentation={config.presentation}+ placement="below"+ width="100%"+ isDefaultOpen+ />+ </div>+ </Theme>+ ),+ play: async ({canvasElement}) => {+ await waitFor(() => {+ expect(document.querySelector('[role="listbox"]')).not.toBeNull();+ });+ await document.fonts.ready;+ await new Promise<void>(resolve =>+ requestAnimationFrame(() => requestAnimationFrame(() => resolve())),+ );++ const selector = canvasElement.querySelector<HTMLElement>(+ `[data-ast004-indicator-space="${config.name}"]`,+ );+ const listbox = document.querySelector<HTMLElement>('[role="listbox"]');+ const selectedRow = listbox?.querySelector<HTMLElement>(+ '[role="option"][aria-selected="true"]',+ );+ const unselectedRow = listbox?.querySelector<HTMLElement>(+ '[role="option"][aria-selected="false"]',+ );+ if (+ selector == null ||+ listbox == null ||+ selectedRow == null ||+ unselectedRow == null+ ) {+ throw new Error(`AST-004 evidence did not render ${config.name}`);+ }+ expect(getComputedStyle(selectedRow).direction).toBe(config.direction);++ const markColumn = (row: HTMLElement) =>+ (config.indicatorPosition === 'start'+ ? row.firstElementChild+ : row.lastElementChild) as HTMLElement;+ const contentColumn = (row: HTMLElement) =>+ (config.indicatorPosition === 'start'+ ? row.lastElementChild+ : row.firstElementChild) as HTMLElement;+ const selectedMark = markColumn(selectedRow);+ const unselectedMark = markColumn(unselectedRow);+ const selectedContent = contentColumn(selectedRow);+ const unselectedContent = contentColumn(unselectedRow);++ expect(selectedMark.getBoundingClientRect().width).toBeGreaterThan(0);+ if (config.usesRadioIndicator) {+ expect(unselectedMark.getBoundingClientRect().width).toBeGreaterThan(0);+ expect(+ Math.abs(+ selectedContent.getBoundingClientRect().width -+ unselectedContent.getBoundingClientRect().width,+ ),+ ).toBeLessThanOrEqual(1);+ } else {+ expect(getComputedStyle(unselectedMark).display).toBe('none');+ expect(unselectedMark.getBoundingClientRect().width).toBe(0);+ expect(unselectedContent.getBoundingClientRect().width).toBeGreaterThan(+ selectedContent.getBoundingClientRect().width,+ );+ }++ expect(selectedContent.textContent).toContain(+ 'Selected option with a deliberately long readable label',+ );+ expect(unselectedContent.textContent).toContain(+ 'Unselected option with a deliberately long readable label',+ );+ expect(selectedContent.getBoundingClientRect().width).toBeGreaterThan(0);+ expect(unselectedContent.getBoundingClientRect().width).toBeGreaterThan(+ 0,+ );++ const markRect = selectedMark.getBoundingClientRect();+ const contentRect = selectedContent.getBoundingClientRect();+ const markIsAtInlineStart =+ config.direction === 'rtl'+ ? markRect.left >= contentRect.right+ : markRect.right <= contentRect.left;+ expect(markIsAtInlineStart).toBe(config.indicatorPosition === 'start');++ if (config.presentation === 'popover') {+ const popup = document.querySelector<HTMLElement>(+ '.astryx-selector-popup',+ );+ if (popup == null) {+ throw new Error(+ `AST-004 Popover evidence did not render ${config.name}`,+ );+ }+ const popoverHost = popup.closest<HTMLElement>('[popover]');+ if (popoverHost == null) {+ throw new Error(`AST-004 Popover host did not render ${config.name}`);+ }+ expect(popoverHost.matches(':popover-open')).toBe(true);+ } else {+ const dialog = document.querySelector<HTMLDialogElement>('dialog');+ if (dialog == null) {+ throw new Error(+ `AST-004 BottomSheet evidence did not render ${config.name}`,+ );+ }+ expect(dialog.matches(':modal')).toBe(true);+ }+ },+ };+}++export const IndicatorSpacePopoverNarrowStart: Story = {+ ...createIndicatorSpaceEvidenceStory({+ name: 'popover-narrow-start-default-ltr',+ presentation: 'popover',+ width: '12rem',+ indicatorPosition: 'start',+ direction: 'ltr',+ usesRadioIndicator: false,+ }),+ tags: ['visual-baseline'],+};++export const IndicatorSpacePopoverWideEndRTL: Story = {+ ...createIndicatorSpaceEvidenceStory({+ name: 'popover-wide-end-radio-rtl',+ presentation: 'popover',+ width: '24rem',+ indicatorPosition: 'end',+ direction: 'rtl',+ usesRadioIndicator: true,+ }),+ tags: ['visual-baseline'],+};++export const IndicatorSpaceBottomSheetNarrowEndRTL: Story = {+ ...createIndicatorSpaceEvidenceStory({+ name: 'bottom-sheet-narrow-end-default-rtl',+ presentation: 'bottom-sheet',+ width: '12rem',+ indicatorPosition: 'end',+ direction: 'rtl',+ usesRadioIndicator: false,+ }),+ tags: ['visual-baseline'],+};++export const IndicatorSpaceBottomSheetWideStart: Story = {+ ...createIndicatorSpaceEvidenceStory({+ name: 'bottom-sheet-wide-start-radio-ltr',+ presentation: 'bottom-sheet',+ width: '24rem',+ indicatorPosition: 'start',+ direction: 'ltr',+ usesRadioIndicator: true,+ }),+ tags: ['visual-baseline'],+};diff --git a/packages/core/src/Selector/Selector.doc.mjs b/packages/core/src/Selector/Selector.doc.mjsindex 681542ee16..9dbf5efe14 100644--- a/packages/core/src/Selector/Selector.doc.mjs+++ b/packages/core/src/Selector/Selector.doc.mjs@@ -83,7 +83,7 @@ const anatomy = [name: 'Option selection indicator',required: false,description:- 'Resolved selection mark rendered for each option in its checked or unchecked state.',+ 'Resolved selection mark rendered for each option in its checked or unchecked state. Its layout space collapses when the resolved indicator draws nothing.',},{name: 'Option divider',@@ -330,7 +330,7 @@ export const docs = {name: 'indicatorPosition',type: "'start' | 'end'",description:- 'Which edge of the option row carries the selected mark. start reserves a mark column ahead of every label so they stay aligned, the way a native menu does; end is the house convention shared with Typeahead and CommandPalette.',+ 'Which logical edge of the option row carries a rendered selection mark. An empty mark consumes no space, so selected and unselected labels may shift or have different available width. end is the house convention shared with Typeahead and CommandPalette.',default: "'end'",},{diff --git a/packages/core/src/Selector/Selector.spec.md b/packages/core/src/Selector/Selector.spec.mdindex 7ae2f66341..1a96161e47 100644--- a/packages/core/src/Selector/Selector.spec.md+++ b/packages/core/src/Selector/Selector.spec.md@@ -16,6 +16,8 @@ verified_by:packages/core/src/Selector/Selector.source-build.test.mjs,packages/core/src/Selector/__tests__/Selector.listbox.a11y.test.tsx,packages/core/src/Selector/__tests__/Listbox.a11y.chromium.spec.ts,+ apps/storybook/stories/Selector.stories.tsx,+ .github/scripts/story-play-guard.js,]modules: []families: [family:input-fields]@@ -44,8 +46,8 @@ connection between the closed trigger and its selection surface.## Compatibility and migration- Released defaults and behavior remain unchanged by this record.-- `indicatorPosition` defaults to `end`; every option row currently reserves the- indicator column at the configured logical edge.+- `indicatorPosition` defaults to `end`; a rendered selection mark occupies+ space at that logical edge, while an empty resolved indicator occupies none.- `presentation` defaults to `popover`. `bottom-sheet` is an explicit modalpresentation, and `adaptive` selects it on compact coarse-pointer screens.- `hasClear` changes the value contract to include `null`; that distinction is@@ -53,9 +55,7 @@ connection between the closed trigger and its selection surface.- `isReadOnly` is additive and defaults to `false`. It preserves the selectedvalue, focus, and form participation while removing selection-surface andediting affordances. `isDisabled` takes precedence when both are set.-- `spec:AST-004/DEC-1` accepts a future change that collapses an empty indicator- column. It is not shipped behavior and does not replace FR3 until implementation,- visual verification, and an update to this current contract land together.+- `spec:AST-004/DEC-1` governs the state-derived indicator-space behavior in FR3.## Ownership boundary@@ -86,7 +86,7 @@ and examples remain in `Selector.doc.mjs`.| ---------------------- | -------------------------------------- | -------------------------------------------------------- | ----------------------------------------- | --------- | -------- | --------- | ------------------------------- || trigger variant | `input`, `ghost` | Form-field or toolbar presentation | All trigger states | `input` | Selector | released | TypeScript rejects other values || size | `sm`, `md`, `lg` | Trigger and option-row density | All presentations | `md` | Selector | released | TypeScript rejects other values |-| selected-mark position | `start`, `end` | Logical edge containing the reserved selection column | Every option row | `end` | Selector | released | TypeScript rejects other values |+| selected-mark position | `start`, `end` | Logical edge containing a rendered selection mark | Every option row | `end` | Selector | released | TypeScript rejects other values || presentation | `popover`, `bottom-sheet`, `adaptive` | Anchored pointer surface or modal compact-touch surface | All trigger variants | `popover` | Selector | released | TypeScript rejects other values || popup semantics | `listbox`; modal dialog containing one | Semantics follow the active presentation | Popover; bottom sheet | `listbox` | Selector | released | No separate role prop is public || option-row state | `selected`, `disabled` | Stable theming state on each option row | Every rendered option | neither | Selector | released | Unknown states are not emitted |@@ -96,20 +96,20 @@ and examples remain in `Selector.doc.mjs`.These requirements describe shipped behavior on current `main`.-| ID | Shipped invariant | Evidence |-| --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |-| FR1 | Selecting an enabled option updates the one selected value, closes the active presentation, and returns the trigger to its stable closed state. | Consumer docs and selection interaction tests |-| FR2 | Without explicit placement, a non-search popover aligns the selected row over the trigger and clamps it to the viewport. Search popovers and explicit placement use normal Layer positioning. | Consumer docs, implementation, and geometry tests |-| FR3 | Every option row reserves one selection-mark column at `indicatorPosition`, even when the default unchecked indicator draws nothing. The column has a minimum width and can grow for a larger themed replacement. | `itemMarkColumn`, indicator-position tests, and theme tests |-| FR4 | `popover` uses an anchored Popover. `bottom-sheet` uses a modal BottomSheet. `adaptive` resolves to the modal bottom sheet on compact coarse-pointer screens and Popover otherwise. | Presentation controller and adaptive-presentation tests |-| FR5 | While `isLoading` is true, the trigger exposes busy state and the listbox suppresses empty and no-results output. | Loading, empty-state, and announcement tests |-| FR6 | While `isReadOnly` is true, the selected value remains focusable and form-submittable, while the selection surface, clear action, disclosure indicator, and every value-change path are unavailable. | Read-only interaction, form, and accessibility tests |+| ID | Shipped invariant | Evidence |+| --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |+| FR1 | Selecting an enabled option updates the one selected value, closes the active presentation, and returns the trigger to its stable closed state. | Consumer docs and selection interaction tests |+| FR2 | Without explicit placement, a non-search popover aligns the selected row over the trigger and clamps it to the viewport. Search popovers and explicit placement use normal Layer positioning. | Consumer docs, implementation, and geometry tests |+| FR3 | An option whose resolved selection indicator draws no content reserves no mark-column space. Visible selected or themed replacement indicators remain in layout at `indicatorPosition`; the resulting state-dependent label position or available width is intentional, and row content keeps its existing overflow behavior. | `itemMarkColumn`, focused indicator tests, and Chromium evidence stories |+| FR4 | `popover` uses an anchored Popover. `bottom-sheet` uses a modal BottomSheet. `adaptive` resolves to the modal bottom sheet on compact coarse-pointer screens and Popover otherwise. | Presentation controller and adaptive-presentation tests |+| FR5 | While `isLoading` is true, the trigger exposes busy state and the listbox suppresses empty and no-results output. | Loading, empty-state, and announcement tests |+| FR6 | While `isReadOnly` is true, the selected value remains focusable and form-submittable, while the selection surface, clear action, disclosure indicator, and every value-change path are unavailable. | Read-only interaction, form, and accessibility tests |### Allowed variation-- **AV1 — Indicator rendering.** A theme may replace the check indicator. The- replacement may draw in both selected and unselected states; the current row- still reserves its indicator column.+- **AV1 — Indicator rendering.** A theme may replace the check indicator. A+ replacement that draws in both selected and unselected states keeps its mark+ space in both states; only resolved empty output collapses.- **AV2 — Option content.** `renderOption` may replace visible option content,while Selector keeps row role, selection, disabled state, navigation, andtheming state.@@ -118,17 +118,17 @@ These requirements describe shipped behavior on current `main`.### Representative states-| State | Required invariant | Allowed variation |-| ------------------------ | ----------------------------------------------------------------------------------------- | ------------------------------------------------------ |-| closed with no value | Label and placeholder identify the field | Consumer placeholder text |-| closed with a value | Selected option is represented in the trigger | Custom `renderValue` content |-| pointer / popover | Anchored surface exposes the listbox without modal-dialog semantics | Default or explicit placement |-| compact coarse pointer | BottomSheet exposes a modal dialog containing the listbox | Explicit `bottom-sheet` or resolved `adaptive` |-| searching | Visible options, keyboard navigation, and announced result count use one filter | Consumer search and empty text |-| loading | Trigger is busy; empty and no-results output is suppressed | Consumer loading duration |-| disabled with reason | Trigger remains focusable enough to expose the reason while activation stays blocked | Consumer reason text |-| read-only | Value stays focusable and submittable; menu, clear, and disclosure affordances are absent | Value rendering, status, and busy presentation |-| selected/unselected rows | Row semantics and theming state are correct; both reserve the indicator column | Start/end position and themed indicator representation |+| State | Required invariant | Allowed variation |+| ------------------------ | ----------------------------------------------------------------------------------------- | ---------------------------------------------------------- |+| closed with no value | Label and placeholder identify the field | Consumer placeholder text |+| closed with a value | Selected option is represented in the trigger | Custom `renderValue` content |+| pointer / popover | Anchored surface exposes the listbox without modal-dialog semantics | Default or explicit placement |+| compact coarse pointer | BottomSheet exposes a modal dialog containing the listbox | Explicit `bottom-sheet` or resolved `adaptive` |+| searching | Visible options, keyboard navigation, and announced result count use one filter | Consumer search and empty text |+| loading | Trigger is busy; empty and no-results output is suppressed | Consumer loading duration |+| disabled with reason | Trigger remains focusable enough to expose the reason while activation stays blocked | Consumer reason text |+| read-only | Value stays focusable and submittable; menu, clear, and disclosure affordances are absent | Value rendering, status, and busy presentation |+| selected/unselected rows | Empty marks consume no width; visible marks retain space at the logical edge | State-dependent label position/width and themed indicators |### Transformation and precedence order@@ -176,12 +176,12 @@ These requirements describe shipped behavior on current `main`.No current design spec is linked.-| Anatomy or state | Current representation requirement | Representation authority | Hierarchy role | Component contract |-| -------------------------------- | --------------------------------------------------------------------------------------- | -------------------------- | ----------------------- | ------------------ |-| selected mark and option spacing | Every row reserves the indicator column, preserving label alignment and available width | existing shipped behavior | supporting | FR3 |-| input versus ghost trigger | none recorded | existing released behavior | form or toolbar control | Public concepts |+| Anatomy or state | Current representation requirement | Representation authority | Hierarchy role | Component contract |+| -------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------- | ----------------------- | ------------------ |+| selected mark and option spacing | Empty resolved marks collapse; visible marks retain space, so row label geometry may vary by state | `spec:AST-004/DEC-1` | supporting | FR3 |+| input versus ghost trigger | none recorded | existing released behavior | form or toolbar control | Public concepts |-The approved but unimplemented replacement for the first row is owned by+The first row implements the state-derived spacing decision in`spec:AST-004/DEC-1`.### Theming anatomy@@ -257,16 +257,15 @@ content stays outside that target, while the targeted option row remains.current anatomy row.This map records only shipped reachability. It does not treat the accepted,-unimplemented option-source behavior in `spec:AST-001` or indicator-space change-in `spec:AST-004` as current runtime behavior.+unimplemented option-source behavior in `spec:AST-001` as current runtime behavior.+`spec:AST-004` governs FR3's shipped indicator-space behavior without adding a+new theming target.## Family and system relationships- The current architecture links in frontmatter own public API, theming, iconresolution, interaction modality, and Layer behavior used by Selector.-- `spec:AST-004/DEC-1` owns the accepted future indicator-space change. Its- `accepted` phase is direction for implementation, not evidence that the runtime- has changed.+- `spec:AST-004/DEC-1` owns FR3's shipped indicator-space behavior.- `spec:AST-011/DEC-1` owns the additive read-only state: caller-owned policy canpreserve a focusable, submittable value without exposing selection controls.- `family:input-fields` owns family-wide state display, behavior, appearance,@@ -276,21 +275,21 @@ in `spec:AST-004` as current runtime behavior.## Verification map-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |-| --------------------- | -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |-| FR1, AR2, AR3 | `Selector.test.tsx` selection, focus, and keyboard suites | closed/open, search/non-search, disabled option | Removing selection wiring, focus movement, or keyboard behavior fails the named interaction tests | `audit:Selector/behavior` |-| FR2 | placement and selected-item geometry tests | default, explicit, RTL, transformed entry | Using the wrong positioning model fails the expected position-area or margin | `audit:Selector/behavior` |-| FR3, AV1 | `itemMarkColumn` source inspection plus indicator-position and replacement-indicator tests | start/end, selected/unselected, check/radio | Removing the wrapper fails row-structure tests; changing its reserved width requires source/layout review | `audit:Selector/design-rendered` |-| FR4, AR1, AR2 | presentation tests plus `aria-haspopup` source review | pointer, compact coarse pointer, search/non-search | Wrong Popover/dialog roles or focus destinations fail tests; `aria-haspopup` values require source/a11y review | `audit:Selector/accessibility` |-| AR1, AV2 | `Selector.listbox.a11y.test.tsx` and `Listbox.a11y.chromium.spec.ts` against the shared Listbox contract | popover/sheet, flat/grouped, selected/unselected, disabled, search, loading, custom RTL | A new or wider loss of role, listbox/option name, state, or ownership gates; the exact unnamed no-search sheet state remains known debt | `audit:Selector/accessibility` |-| FR5 | loading, empty-state, and live-region tests | empty options, unmatched search, loading | Empty/no-results output appears or is announced while loading | `audit:Selector/behavior` |-| FR6, AR4 | read-only interaction, form, ARIA, and theme-state tests | search/non-search, clearable, open→read-only, disabled precedence | A value changes, popup or edit affordance remains, form value disappears, or read-only semantics are absent | `audit:Selector/accessibility` |-| source-build contract | `Selector.source-build.test.mjs` | package source compiled by consumer Babel | Moving evaluated StyleX values outside the supported source form fails compilation | `audit:Selector/code-health` |+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |+| --------------------- | -------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |+| FR1, AR2, AR3 | `Selector.test.tsx` selection, focus, and keyboard suites | closed/open, search/non-search, disabled option | Removing selection wiring, focus movement, or keyboard behavior fails the named interaction tests | `audit:Selector/behavior` |+| FR2 | placement and selected-item geometry tests | default, explicit, RTL, transformed entry | Using the wrong positioning model fails the expected position-area or margin | `audit:Selector/behavior` |+| FR3, AV1 | Focused `Selector.test.tsx` computed-display checks plus guarded Chromium Storybook matrix and stable visual stories | popover/bottom sheet, narrow/wide, start/end, LTR/RTL, selected/unselected, check/radio | Empty output reserves width, visible output collapses, logical placement flips incorrectly, or row content overflows | `audit:Selector/design-rendered` |+| FR4, AR1, AR2 | presentation tests plus `aria-haspopup` source review | pointer, compact coarse pointer, search/non-search | Wrong Popover/dialog roles or focus destinations fail tests; `aria-haspopup` values require source/a11y review | `audit:Selector/accessibility` |+| AR1, AV2 | `Selector.listbox.a11y.test.tsx` and `Listbox.a11y.chromium.spec.ts` against the shared Listbox contract | popover/sheet, flat/grouped, selected/unselected, disabled, search, loading, custom RTL | A new or wider loss of role, listbox/option name, state, or ownership gates; the exact unnamed no-search sheet state remains known debt | `audit:Selector/accessibility` |+| FR5 | loading, empty-state, and live-region tests | empty options, unmatched search, loading | Empty/no-results output appears or is announced while loading | `audit:Selector/behavior` |+| FR6, AR4 | read-only interaction, form, ARIA, and theme-state tests | search/non-search, clearable, open→read-only, disabled precedence | A value changes, popup or edit affordance remains, form value disappears, or read-only semantics are absent | `audit:Selector/accessibility` |+| source-build contract | `Selector.source-build.test.mjs` | package source compiled by consumer Babel | Moving evaluated StyleX values outside the supported source form fails compilation | `audit:Selector/code-health` |## Decision log-No component-local future decision is recorded here. Accepted unimplemented work-is owned by `spec:AST-004`.+No component-local future decision is recorded here. FR3 implements the+system decision owned by `spec:AST-004/DEC-1`.## Open questionsdiff --git a/packages/core/src/Selector/Selector.test.tsx b/packages/core/src/Selector/Selector.test.tsxindex 25471bca4c..84ec70f995 100644--- a/packages/core/src/Selector/Selector.test.tsx+++ b/packages/core/src/Selector/Selector.test.tsx@@ -3728,67 +3728,73 @@ describe('Selector indicatorPosition', () => {).toBeTruthy();});- it('reserves the mark column on every row, at either position', () => {- // The default check draws nothing when unchecked, so without a reserved- // column the chosen row would be laid out differently from the rest —- // indented at the start, truncating earlier at the end. Every row is two- // children wide either way, so a row's geometry does not depend on whether- // it happens to be the chosen one.- const {unmount} = render(- <Selector- label="Fruit"- options={OPTIONS}- value="Banana"- onChange={() => {}}- indicatorPosition="start"- isDefaultOpen- />,- );- for (const row of openRows()) {- expect(row.children).toHaveLength(2);- }- unmount();-- render(- <Selector- label="Fruit"- options={OPTIONS}- value="Banana"- onChange={() => {}}- isDefaultOpen- />,- );- for (const row of openRows()) {- expect(row.children).toHaveLength(2);- }- });-- it('positions a themed replacement indicator the same way', () => {- const theme = defineTheme({- name: 'selector-start-radio-mark-test',- indicators: {check: RadioIndicator},- });- render(- <Theme theme={theme}>+ it.each(['start', 'end'] as const)(+ 'collapses an empty default mark at the logical %s edge',+ indicatorPosition => {+ render(<Selectorlabel="Fruit"options={OPTIONS}value="Banana"onChange={() => {}}- indicatorPosition="start"+ indicatorPosition={indicatorPosition}isDefaultOpen- />- </Theme>,- );- for (const row of openRows()) {- const radio = row.querySelector('.astryx-radio')!;- const content = row.querySelector('.astryx-selector-option')!;- expect(- content.compareDocumentPosition(radio) &- Node.DOCUMENT_POSITION_PRECEDING,- ).toBeTruthy();- }- });+ />,+ );++ for (const row of openRows()) {+ const isSelected = row.getAttribute('aria-selected') === 'true';+ const markColumn =+ indicatorPosition === 'start'+ ? row.firstElementChild+ : row.lastElementChild;+ expect(markColumn).not.toBeNull();+ expect(markColumn).toHaveStyle({+ display: isSelected ? 'inline-flex' : 'none',+ });+ }+ },+ );++ it.each(['start', 'end'] as const)(+ 'keeps a themed indicator in layout at the logical %s edge',+ indicatorPosition => {+ const theme = defineTheme({+ name: `selector-${indicatorPosition}-radio-mark-test`,+ indicators: {check: RadioIndicator},+ });+ render(+ <Theme theme={theme}>+ <Selector+ label="Fruit"+ options={OPTIONS}+ value="Banana"+ onChange={() => {}}+ indicatorPosition={indicatorPosition}+ isDefaultOpen+ />+ </Theme>,+ );++ for (const row of openRows()) {+ const markColumn =+ indicatorPosition === 'start'+ ? row.firstElementChild+ : row.lastElementChild;+ const radio = row.querySelector('.astryx-radio');+ const content = row.querySelector('.astryx-selector-option');+ expect(markColumn).toHaveStyle({display: 'inline-flex'});+ expect(radio).not.toBeNull();+ expect(content).not.toBeNull();+ expect(+ content!.compareDocumentPosition(radio!) &+ (indicatorPosition === 'start'+ ? Node.DOCUMENT_POSITION_PRECEDING+ : Node.DOCUMENT_POSITION_FOLLOWING),+ ).toBeTruthy();+ }+ },+ );});describe('Selector popup theme target', () => {diff --git a/packages/core/src/Selector/Selector.tsx b/packages/core/src/Selector/Selector.tsxindex cbc7647fc7..3c15352ca1 100644--- a/packages/core/src/Selector/Selector.tsx+++ b/packages/core/src/Selector/Selector.tsx@@ -4,15 +4,17 @@/*** @file Selector.tsx- * @input Uses React, StyleX, usePopover, useTooltip, Icon, InputGroupContext,- * and Selector positioning hooks- * @output Exports Selector component+ * @input Uses React, StyleX, adaptive selection surfaces, theme-resolved+ * indicators, Field, and InputGroup context+ * @output Exports Selector with content-derived option-mark layout* @position Core implementation; consumed by index.ts** SYNC: When modified, update:+ * - /packages/core/src/Selector/Selector.spec.md* - /packages/core/src/Selector/Selector.doc.mjs* - /packages/core/src/Selector/Selector.test.tsx* - /packages/core/src/Selector/index.ts+ * - /apps/storybook/stories/Selector.stories.tsx* - /apps/storybook/stories/InputGroup.stories.tsx* - /packages/cli/assets/templates/blocks/components/Selector/ (showcase blocks)*/@@ -367,18 +369,20 @@ const styles = stylex.create({flex: 1,minWidth: 0,},- // The mark's column, reserved on every row and at either position, so a row- // occupies the same geometry whether or not it is the chosen one — the- // default check draws nothing when unchecked, and without the column a list- // would indent (or truncate) its chosen row differently from the rest.- // `minWidth` rather than `width`: a theme can replace `check` with a larger- // indicator (a radio is 20px at `sm`), and the column has to grow with it.+ // The wrapper keeps a visible mark at either logical position and lets a+ // replacement indicator grow beyond the default 1rem minimum. When the+ // resolved indicator draws nothing, `:empty` removes the wrapper from layout+ // instead of reserving blank space. Selected and unselected labels may+ // therefore shift or have different available width by design (AST-004).itemMarkColumn: {display: 'inline-flex',alignItems: 'center',justifyContent: 'center',flexShrink: 0,minWidth: '1rem',+ ':empty': {+ display: 'none',+ },},itemCheckmark: {flexShrink: 0,@@ -654,10 +658,10 @@ interface SelectorPropsBase<renderValue?: (option: SelectorOptionData) => ReactNode;/**- * Which edge of the option row carries the selected mark. `start` reserves a- * mark column ahead of every label so they stay aligned, the way a native- * menu does; `end` is the house convention shared with Typeahead and- * CommandPalette.+ * Which logical edge of the option row carries a rendered selection mark. An+ * empty mark consumes no space, so selected and unselected labels may shift or+ * have different available width. `end` is the house convention shared with+ * Typeahead and CommandPalette.** @default 'end'*/