An open source design system that's fully customizable and agent ready
TypeScript
[Component Audit] DateInput: busy fields stop looking disabled (#7968)
Cindy Zhangd648470ad49c
diff --git a/.changeset/date-input-busy-paint.md b/.changeset/date-input-busy-paint.mdnew file mode 100644index 0000000000..c670e25688--- /dev/null+++ b/.changeset/date-input-busy-paint.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] A busy `DateInput` (`isLoading`, or a pending `changeAction`) no longer looks disabled. On the popover, native, and bottom-sheet surfaces the field keeps its ordinary paint and shows its Spinner while new commits are blocked; only `isDisabled` dims the field. The busy field still takes no hover ring and keeps its keyboard focus ring. Props, semantics, and announcements are unchanged.++@cixzhangdiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 010db5af96..1002b734fc 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -3139,12 +3139,15 @@ jobs:# DateInput's open-state audit story uses a play function to open the# popover. Restricting this focused pass to that story lets the selector# wait bind axe to the Calendar dialog without making every DateInput story- # require an open overlay.+ # require an open overlay. The receipt spec then captures rest, focus,+ # busy, disabled, status, and open states across the popover, native, and+ # bottom-sheet surfaces, themes, direction, pointers, and viewport.- name: Run DateInput audit browser evidence- if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, '[Component Audit] DateInput:')+ if: ${{ !cancelled() && github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, '[Component Audit] DateInput:') }}env:ASTRYX_HEAD_SHA: ${{ github.event.pull_request.head.sha }}run: |+ status=0node .github/scripts/accessibility-audit.js \--storybook-dir apps/storybook/dist \--output date-input-a11y-report.json \@@ -3152,14 +3155,20 @@ jobs:--stories core-dateinput--open-calendar-audit \--ready-selector '[role="dialog"]' \--baseline .github/a11y-baseline.json \- --fail-on-new+ --fail-on-new || status=1+ pnpm exec playwright test \+ packages/core/src/DateInput/__tests__/DateInputAudit.a11y.chromium.spec.ts \+ --project chromium || status=1+ exit "$status"- name: Upload DateInput audit evidenceif: always() && github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, '[Component Audit] DateInput:')uses: actions/upload-artifact@v7with:name: date-input-audit-evidence-${{ needs.build-storybook.outputs.short_hash }}- path: date-input-a11y-report.json+ path: |+ date-input-a11y-report.json+ date-input-audit-evidence/retention-days: 30if-no-files-found: errordiff --git a/packages/cli/test/__golden__/no-icon-set/search-close.json b/packages/cli/test/__golden__/no-icon-set/search-close.jsonindex b349cc7cc6..abf4a4facc 100644--- a/packages/cli/test/__golden__/no-icon-set/search-close.json+++ b/packages/cli/test/__golden__/no-icon-set/search-close.json@@ -3,7 +3,7 @@"type": "search","data": {"query": "close",- "matchCount": 43,+ "matchCount": 44,"results": [{"domain": "component",diff --git a/packages/cli/test/__golden__/no-icon-set/search-close.txt b/packages/cli/test/__golden__/no-icon-set/search-close.txtindex 0dc2095568..57026ef943 100644--- a/packages/cli/test/__golden__/no-icon-set/search-close.txt+++ b/packages/cli/test/__golden__/no-icon-set/search-close.txt@@ -1,4 +1,4 @@-Results for "close" (20 of 43)+Results for "close" (20 of 44)name: AlertDialogdomain: componentpackage: @astryxdesign/corediff --git a/packages/core/src/DateInput/DateInput.doc.mjs b/packages/core/src/DateInput/DateInput.doc.mjsindex d2267c4d16..27fa65ef6b 100644--- a/packages/core/src/DateInput/DateInput.doc.mjs+++ b/packages/core/src/DateInput/DateInput.doc.mjs@@ -79,7 +79,7 @@ export const docs = {name: 'isLoading',type: 'boolean',description:- 'Whether the input is in a loading state. Disables interaction and shows a spinner.',+ 'Whether the input is in a loading state. The field stays focusable and exposes `aria-busy` with a spinner; typing, picking, and clearing are blocked until loading ends.',default: 'false',},{@@ -253,6 +253,11 @@ export const docs = {description:'Show a loading state with changeAction when the date triggers a server-side save.',},+ {+ guidance: true,+ description:+ 'On a fine pointer the field follows the WAI-ARIA combobox pattern with a dialog popup, as in the APG date picker combobox: ArrowDown or Alt+ArrowDown opens the calendar, and Escape closes it and returns focus to the field.',+ },{guidance: true,description:@@ -301,7 +306,7 @@ export const docs = {name: 'Calendar popover',required: false,description:- 'A month grid that appears when the icon is clicked or the input is focused.',+ 'A month grid that appears when the icon or the input is clicked, or when ArrowDown is pressed in the input.',},{name: 'Clear button',@@ -351,6 +356,11 @@ export const docsZh = {description:'Show a loading state with changeAction when the date triggers a server-side save.',},+ {+ guidance: true,+ description:+ 'On a fine pointer the field follows the WAI-ARIA combobox pattern with a dialog popup, as in the APG date picker combobox: ArrowDown or Alt+ArrowDown opens the calendar, and Escape closes it and returns focus to the field.',+ },{guidance: false,description:@@ -401,7 +411,8 @@ export const docsZh = {{name: 'isDisabled',type: 'boolean',- description: '禁用输入框和日历。输入框仍可聚焦并暴露 `aria-disabled`,但不能输入或打开日历。',+ description:+ '禁用输入框和日历。输入框仍可聚焦并暴露 `aria-disabled`,但不能输入或打开日历。',default: 'false',},{@@ -429,7 +440,8 @@ export const docsZh = {{name: 'isLoading',type: 'boolean',- description: '输入框是否处于加载状态。禁用交互并显示加载指示器。',+ description:+ '输入框是否处于加载状态。字段仍可聚焦,并通过 `aria-busy` 和加载指示器表示忙碌;加载结束前不能输入、选择或清除日期。',default: 'false',},{@@ -599,6 +611,11 @@ export const docsDense = {description:'Show a loading state with changeAction when the date triggers a server-side save.',},+ {+ guidance: true,+ description:+ 'On a fine pointer the field follows the WAI-ARIA combobox pattern with a dialog popup, as in the APG date picker combobox: ArrowDown or Alt+ArrowDown opens the calendar, and Escape closes it and returns focus to the field.',+ },{guidance: true,description:@@ -638,7 +655,8 @@ export const docsDense = {value: 'selected date YYYY-MM-DD',onChange: 'callback on date change',changeAction: 'async action after onChange; drives optimistic UI',- isLoading: 'loading state; disables interaction, shows spinner',+ isLoading:+ 'loading state; stays focusable w/ aria-busy + spinner; blocks typing, picking, clearing',min: 'min selectable date (YYYY-MM-DD)',max: 'max selectable date (YYYY-MM-DD)',dateConstraints: 'custom constraint fns to disable specific dates',diff --git a/packages/core/src/DateInput/DateInput.spec.md b/packages/core/src/DateInput/DateInput.spec.mdindex 9bbbb8156e..42c8b3a1f8 100644--- a/packages/core/src/DateInput/DateInput.spec.md+++ b/packages/core/src/DateInput/DateInput.spec.md@@ -17,6 +17,7 @@ verified_by:packages/core/src/DateInput/DateInputTouch.test.tsx,packages/core/src/DateInput/NativeDateField.test.tsx,packages/core/src/DateInput/Presentation.test.tsx,+ packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx,packages/core/src/theme/themingTargets.test.ts,scripts/check-knowledge.mjs,]@@ -30,26 +31,25 @@ architecture:architecture:public-component-api,]contributing: []-system_specs: [spec:AST-043]+system_specs: [spec:AST-043, spec:AST-085, spec:AST-086]---# DateInput component contract-This draft records shipped behavior plus one objective conformance fix already settled-by `family:input-fields/FR6`. It does not approve a new public API, default,+This draft records shipped behavior. It does not approve a new public API, default,compatibility promise, ownership boundary, or visual direction.## Contract at a glance-| Area | Contract |-| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| Public contract | API shape and defaults remain unchanged. The native-picker surface now follows the existing `changeAction` order, optimistic-value, and busy-feedback contract. |-| Behavior | `presentation` selects the picker surface; an omitted value remains `adaptive-native`; `presentation` wins over deprecated `nativePicker`; every committed path emits the same controlled ISO-date value and action feedback. |-| End-user impact | People can type or pick one date using a surface suited to the primary pointer; native-picker saves now run instead of being silently dropped. |-| Builder impact | Existing native DateInput `changeAction` handlers now run after `onChange` and receive optimistic busy feedback. No API or migration work is required. |-| Compatibility/readiness | Compatible patch correction under the current input-field family rule. Released defaults and controlled ownership are preserved; exact-head browser evidence remains audit evidence rather than product authority. |-| Review checks | Reject a surface-mapping change, lost constraint, callback-order change, unlabeled field, unreachable disabled reason, changed close behavior, or a theming target placed on the wrong owner. |-| Governing rules | `spec:AST-043/FR1–FR5`; `family:input-fields/FR1–FR6, FR8–FR10`; `family:overlay-dismissal/FR1–FR7`, including its recorded BottomSheet adoption gap; the three architecture records linked above. |+| Area | Contract |+| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| Public contract | None. API shape and defaults are as shipped; every surface follows the input-field `changeAction`, disabled, and busy contracts. |+| Behavior | `presentation` selects the picker surface; an omitted value is `adaptive-native`; `presentation` wins over deprecated `nativePicker`; every committed path emits the same controlled ISO-date value and action feedback. |+| End-user impact | People type or pick one date using a surface suited to the primary pointer. Disabled and busy fields stay focusable; a busy field keeps its ordinary paint with a Spinner while new commits are blocked. |+| Builder impact | None. `changeAction` runs after `onChange` with optimistic busy feedback on every surface. |+| Compatibility/readiness | Draft observational record of shipped behavior. Released defaults and controlled ownership are preserved; browser evidence remains audit evidence rather than product authority. |+| Review checks | Reject a surface-mapping change, lost constraint, callback-order change, unlabeled field, native `disabled`, disabled paint on a busy-only field, unreachable disabled reason, changed close behavior, or a theming target placed on the wrong owner. |+| Governing rules | `spec:AST-043/FR1–FR5`; `spec:AST-085/FR1–FR6`; `spec:AST-086/FR3, FR4, FR6, FR8`; `family:input-fields/FR1–FR6, FR8–FR11`; `family:overlay-dismissal/FR1–FR7`, including its recorded BottomSheet adoption gap; the three architecture records linked above. |This table is a review projection; the body below is authoritative only after thisrecord becomes `current`.@@ -63,8 +63,8 @@ browser/OS date picker selected by the public presentation contract.## Compatibility and migration- Released default preserved: `yes`-- Compatibility class: compatible patch; no API shape or default changes, and the native- surface now adopts the existing `changeAction` contract instead of dropping it+- Compatibility class: no API shape or default changes; every surface follows the+ input-field `changeAction`, disabled, and busy contracts- Controlled/uncontrolled behavior: unchanged; DateInput remains controlled by`value`, with `undefined` representing no selected date- Migration decision: `spec:AST-043/DEC-1` and `spec:AST-043/DEC-2` own the@@ -121,20 +121,20 @@ Consumer migration instructions belong in consumer docs and release notes.Draft requirements identify their evidence basis; they do not turn observation intoapproved policy.-| ID | Candidate invariant | Basis | Draft review state |-| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | ----------------------------------------- |-| FR1 | DateInput MUST present the controlled ISO `value` and emit `onChange` with the next ISO date or `undefined` without maintaining a competing committed value. | Current source, docs, and focused tests | Verified shipped behavior |-| FR2 | The five `presentation` values MUST resolve to the fine/coarse surfaces in `spec:AST-043/FR1`; omitting both presentation props MUST preserve `adaptive-native`. | `spec:AST-043/FR1–FR3`; Presentation tests | Settled by current system authority |-| FR3 | Explicit `presentation` MUST outrank deprecated `nativePicker`; the legacy values MUST retain their mappings and development-only warning from `spec:AST-043/FR3–FR4`. | Current source, docs, and Presentation tests | Settled by current system authority |-| FR4 | Adaptive resolution MUST use the primary pointer rather than viewport width or any-pointer availability, so tablets receive a touch surface and touchscreen laptops retain the typable field. | Current source, consumer docs, and surface-selection tests | Verified shipped behavior |-| FR5 | Text, Calendar, bottom-sheet, and native commit paths MUST enforce `min`, `max`, and `dateConstraints`; a rejected value MUST NOT replace the controlled value. | Current source and all four focused suites | Verified shipped behavior |-| FR6 | Named committed formats MUST follow the InternationalizationProvider locale and shared Timestamp vocabulary; formatting MUST NOT rewrite in-progress typed text. | Current source, docs, locale tests, `spec:AST-043/FR5` | Verified shipped behavior |-| FR7 | Every value-change path MUST call `onChange` before `changeAction`, present the proposed value optimistically, and expose one busy state while the Action is pending. | `family:input-fields/FR6`; current source and focused tests | Settled shared rule and verified adoption |-| FR8 | The pointer field MUST open its Calendar from the input, calendar toggle, ArrowDown, or Alt+ArrowDown; Popover dismissal and focus return MUST remain owned by the shared Popover path. | Current source, Popover composition, keyboard/focus tests | Verified shipped behavior |-| FR9 | A pointer-surface Calendar selection MUST commit and close its Popover; a bottom-sheet Calendar selection MUST remain editable in the open sheet until Save closes the surface. | Current source and pointer/touch tests | Verified shipped behavior |-| FR10 | Standalone mode MUST compose Field; admitted InputGroup mode MUST remove competing Field chrome while preserving name, description, value, keyboard, focus, and editing semantics. | `family:input-fields/FR3`; current source and InputGroup tests | Settled shared rule and verified adoption |-| FR11 | Clear MUST emit `undefined` through the ordinary change pipeline. The pointer and bottom-sheet surfaces restore field focus using their shipped timing; the native surface MUST NOT reclaim focus because doing so reopens the OS picker. | Current source and focused clear tests | Verified shipped behavior |-| FR12 | Disabled-with-reason MUST remain focusable enough to expose its explanation while blocking mutation. Ordinary disabled and explicit-loading states remain inactive. During a pending Action, pointer and bottom-sheet surfaces remain inactive; the native surface stays focusable so the OS picker remains attached but rejects additional commits until the Action settles. | `family:input-fields/FR4–FR6`; current source and focused tests | Settled shared rule and verified adoption |+| ID | Candidate invariant | Basis | Draft review state |+| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |+| FR1 | DateInput MUST present the controlled ISO `value` and emit `onChange` with the next ISO date or `undefined` without maintaining a competing committed value. | Current source, docs, and focused tests | Verified shipped behavior |+| FR2 | The five `presentation` values MUST resolve to the fine/coarse surfaces in `spec:AST-043/FR1`; omitting both presentation props MUST preserve `adaptive-native`. | `spec:AST-043/FR1–FR3`; Presentation tests | Settled by current system authority |+| FR3 | Explicit `presentation` MUST outrank deprecated `nativePicker`; the legacy values MUST retain their mappings and development-only warning from `spec:AST-043/FR3–FR4`. | Current source, docs, and Presentation tests | Settled by current system authority |+| FR4 | Adaptive resolution MUST use the primary pointer rather than viewport width or any-pointer availability, so tablets receive a touch surface and touchscreen laptops retain the typable field. | Current source, consumer docs, and surface-selection tests | Verified shipped behavior |+| FR5 | Text, Calendar, bottom-sheet, and native commit paths MUST enforce `min`, `max`, and `dateConstraints`; a rejected value MUST NOT replace the controlled value. | Current source and all four focused suites | Verified shipped behavior |+| FR6 | Named committed formats MUST follow the InternationalizationProvider locale and shared Timestamp vocabulary; formatting MUST NOT rewrite in-progress typed text. | Current source, docs, locale tests, `spec:AST-043/FR5` | Verified shipped behavior |+| FR7 | Every value-change path MUST call `onChange` before `changeAction`, present the proposed value optimistically, and expose one busy state while the Action is pending. | `family:input-fields/FR6`; current source and focused tests | Settled shared rule and verified adoption |+| FR8 | The pointer field MUST open its Calendar from the input, calendar toggle, ArrowDown, or Alt+ArrowDown; Popover dismissal and focus return MUST remain owned by the shared Popover path. | Current source, Popover composition, keyboard/focus tests | Verified shipped behavior |+| FR9 | A pointer-surface Calendar selection MUST commit and close its Popover; a bottom-sheet Calendar selection MUST remain editable in the open sheet until Save closes the surface. | Current source and pointer/touch tests | Verified shipped behavior |+| FR10 | Standalone mode MUST compose Field; admitted InputGroup mode MUST remove competing Field chrome while preserving name, description, value, keyboard, focus, and editing semantics. | `family:input-fields/FR3`; current source and InputGroup tests | Settled shared rule and verified adoption |+| FR11 | Clear MUST emit `undefined` through the ordinary change pipeline. The pointer and bottom-sheet surfaces restore field focus using their shipped timing; the native surface MUST NOT reclaim focus because doing so reopens the OS picker. Implementation gap: when the field becomes disabled or busy while its clear control holds focus, the control unmounts and focus falls to the document body; `spec:AST-085/FR4` requires focus to stay or move to a destination this record names. | Current source and focused clear tests; `spec:AST-085/FR4` | Verified shipped behavior |+| FR12 | No surface renders native `disabled`. A disabled field MUST stay focusable with `aria-disabled`, block typing, picking, clearing, and opening, describe its disabled reason when one is given, and take disabled paint. While busy (`isLoading` or a pending Action) the pointer and bottom-sheet surfaces expose `aria-disabled` and `aria-busy`, stay focusable, and block new commits; the native surface does the same for `isLoading`, and during a pending Action stays editable so the OS picker remains attached but rejects additional commits until the Action settles. A busy field that is not disabled keeps its ordinary paint and Spinner, shows no hover ring while commits are blocked, and keeps its keyboard focus ring. | `spec:AST-085/FR1–FR6`; `family:input-fields/FR4–FR6`; `family:buttons/FR4`; current source and focused tests | Settled shared rule and verified adoption |### Allowed variation@@ -152,21 +152,21 @@ approved policy.### Representative states-| State | Required invariant | Allowed variation |-| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |-| empty rest | Labelled field shows the placeholder and calendar affordance without a committed value. | Label, placeholder, size, width |-| committed rest | Field displays the controlled value in the selected committed format. | Format and locale |-| typing | Raw typed text remains visible until commit or reversion. | Parseable text form and locale |-| invalid typed text | Field reflects invalid state, announces the error, and preserves the prior committed value. | Invalid text |-| constrained date | Unreachable dates cannot commit on any surface. | Bound or predicate source |-| popover open | Input reflects expanded dialog state and the Calendar is reachable by pointer and keyboard. | Month count and week start |-| bottom sheet open | Touch calendar remains open across date corrections until Save. | Visible month and wheel state |-| native open/closed | Real date input retains its labelled controlled value while the browser/OS owns picker chrome. | Engine-provided picker |-| disabled | Mutation and activation are blocked. | With or without a reason |-| busy | `aria-busy` and one Spinner expose the save. New commits are blocked; the native picker stays focusable and may move its transient OS highlight without emitting another change. | Explicit loading or pending Action |-| clearable | A committed value has one labelled clear action that emits `undefined`. | Surface and value |-| status | Error, warning, or success remains named and uses shared status presentation. | Status type, message, placement |-| InputGroup | Group owns outer field chrome while DateInput preserves its field semantics. | Group prefix or suffix content |+| State | Required invariant | Allowed variation |+| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |+| empty rest | Labelled field shows the placeholder and calendar affordance without a committed value. | Label, placeholder, size, width |+| committed rest | Field displays the controlled value in the selected committed format. | Format and locale |+| typing | Raw typed text remains visible until commit or reversion. | Parseable text form and locale |+| invalid typed text | Field reflects invalid state, announces the error, and preserves the prior committed value. | Invalid text |+| constrained date | Unreachable dates cannot commit on any surface. | Bound or predicate source |+| popover open | Input reflects expanded dialog state and the Calendar is reachable by pointer and keyboard. | Month count and week start |+| bottom sheet open | Touch calendar remains open across date corrections until Save. | Visible month and wheel state |+| native open/closed | Real date input retains its labelled controlled value while the browser/OS owns picker chrome. | Engine-provided picker |+| disabled | Focusable with `aria-disabled` and disabled paint; mutation and activation are blocked. | With or without a reason |+| busy | `aria-busy` on the control; the composed Spinner is silent and the field announces its busy start once (`spec:AST-086/FR8`). The field keeps its ordinary paint, new commits are blocked, and the native picker stays focusable during a pending Action and may move its transient OS highlight without emitting another change. | Explicit loading or pending Action |+| clearable | A committed value has one labelled clear action that emits `undefined`. | Surface and value |+| status | Error, warning, or success remains named and uses shared status presentation. | Status type, message, placement |+| InputGroup | Group owns outer field chrome while DateInput preserves its field semantics. | Group prefix or suffix content |### Transformation and precedence order@@ -201,8 +201,10 @@ approved policy.- **AR3 — Validation.** Invalid typed or native selections are exposed without coloralone; rejected typed input uses an assertive alert and native rejection remainsdescribed to assistive technology.-- **AR4 — Disabled reason.** A disabled field with a reason remains focusable and- described while all value mutation and picker activation stay blocked.+- **AR4 — Disabled and busy focus.** A disabled or busy field remains focusable and+ exposes its state on the focused control (`spec:AST-085/FR1, FR5`); a disabled+ reason, when given, describes the field's focusable controls while all value+ mutation and picker activation stay blocked.- **AR5 — Native control.** The browser/OS date input remains the labelled value owner;the painted committed-value overlay is excluded from the accessibility tree.- **AR6 — Touch calendar.** The bottom-sheet Calendar preserves one reachable day per@@ -274,6 +276,11 @@ clear-glyph target of its own.policy.- `spec:AST-043` owns the picker presentation vocabulary, default, native fallback,deprecated mapping, and precedence.+- `spec:AST-085` owns focusable disabled and busy controls: no native `disabled`,+ blocked change paths, distinct disabled and busy paint, and focus kept when a+ control becomes inactive.+- `spec:AST-086` owns busy announcements: the composed Spinner is silent and the+ field announces each busy start once.- `architecture:component-theming-surface` owns target admission, painting-elementplacement, state reflection, and anatomy mapping.- `architecture:interaction-modality` owns input-modality principles; DateInput usesdiff --git a/packages/core/src/DateInput/DateInput.tsx b/packages/core/src/DateInput/DateInput.tsxindex b3c1706b3d..914a2c9ca3 100644--- a/packages/core/src/DateInput/DateInput.tsx+++ b/packages/core/src/DateInput/DateInput.tsx@@ -80,8 +80,9 @@ import {import {useDevWarning} from '../hooks/useDevWarning';const styles = stylex.create({- // The shared disabled style drops the focus ring; restore it while this- // field's own input holds focus (spec:AST-085 FR6). Defaults repeat it.+ // While disabled or busy the field takes no hover ring, but the focus ring+ // returns while this field's own input holds focus (spec:AST-085 FR6).+ // Defaults repeat the shared border and shadow.disabledFocusRing: {borderColor: {default: colorVars['--color-border-emphasized'],@@ -292,7 +293,9 @@ export interface DateInputProps extends Omit<changeAction?: (value: ISODateString | undefined) => void | Promise<void>;/**- * Whether the input is in a loading state.+ * Whether the input is in a loading state. The field stays focusable and+ * exposes `aria-busy` with a Spinner; typing, picking, and clearing are+ * blocked until loading ends.* @default false*/isLoading?: boolean;@@ -319,9 +322,9 @@ export interface DateInputProps extends Omit<placeholder?: string;/**- * The size of the input.- * - 'sm': Compact size (18px height)- * - 'md': Default size (26px height)+ * The size of the input. The field height follows the theme's element-size+ * token for the chosen size (`--size-element-sm`, `--size-element-md`, or+ * `--size-element-lg`).* @default 'md'*/size?: DateInputSize;@@ -835,7 +838,10 @@ function PointerDateField({stylex.props(inputWrapperStyles.base,sizeStyles[size],- isEffectivelyDisabled && inputWrapperStyles.disabled,+ // Disabled paint belongs to the disabled state only; a busy field+ // keeps its ordinary paint and shows the Spinner (spec:AST-085+ // FR6, family:buttons FR4).+ isDisabled && inputWrapperStyles.disabled,isEffectivelyDisabled && styles.disabledFocusRing,status && inputStatusBorderStyles[status.type],status &&diff --git a/packages/core/src/DateInput/NativeDateField.tsx b/packages/core/src/DateInput/NativeDateField.tsxindex 42afa51e42..a9723205f8 100644--- a/packages/core/src/DateInput/NativeDateField.tsx+++ b/packages/core/src/DateInput/NativeDateField.tsx@@ -83,7 +83,8 @@ import {import {chainEventHandlers} from '../utils/chainEventHandlers';const styles = stylex.create({- // Same as DateInput's: the focus ring for a focused disabled field.+ // Same as DateInput's: no hover ring while disabled or busy, and the+ // focus ring while the field's input holds focus.disabledFocusRing: {borderColor: {default: colorVars['--color-border-emphasized'],@@ -597,7 +598,10 @@ export function NativeDateField({inputWrapperStyles.base,sizeStyles[size],styles.wrapper,- isEffectivelyDisabled && inputWrapperStyles.disabled,+ // Disabled paint belongs to the disabled state only; a busy field+ // keeps its ordinary paint and shows the Spinner (spec:AST-085+ // FR6, family:buttons FR4).+ isDisabled && inputWrapperStyles.disabled,isEffectivelyDisabled && styles.disabledFocusRing,status && inputStatusBorderStyles[status.type],status &&diff --git a/packages/core/src/DateInput/TouchDateField.tsx b/packages/core/src/DateInput/TouchDateField.tsxindex 49b9cf3f30..27f92f2016 100644--- a/packages/core/src/DateInput/TouchDateField.tsx+++ b/packages/core/src/DateInput/TouchDateField.tsx@@ -167,7 +167,8 @@ const sizeStyles = stylex.create({});const styles = stylex.create({- // Same as DateInput's: the focus ring for a focused disabled field.+ // Same as DateInput's: no hover ring while disabled or busy, and the+ // focus ring while the field's input holds focus.disabledFocusRing: {borderColor: {default: colorVars['--color-border-emphasized'],@@ -1233,7 +1234,10 @@ export function TouchDateField({inputWrapperStyles.base,sizeStyles[size],styles.wrapper,- isEffectivelyDisabled && inputWrapperStyles.disabled,+ // Disabled paint belongs to the disabled state only; a busy field+ // keeps its ordinary paint and shows the Spinner (spec:AST-085+ // FR6, family:buttons FR4).+ isDisabled && inputWrapperStyles.disabled,isEffectivelyDisabled && styles.disabledFocusRing,status && inputStatusBorderStyles[status.type],status &&diff --git a/packages/core/src/DateInput/__tests__/DateInputAudit.a11y.chromium.spec.ts b/packages/core/src/DateInput/__tests__/DateInputAudit.a11y.chromium.spec.tsnew file mode 100644index 0000000000..4a16238382--- /dev/null+++ b/packages/core/src/DateInput/__tests__/DateInputAudit.a11y.chromium.spec.ts@@ -0,0 +1,576 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file DateInputAudit.a11y.chromium.spec.ts+ * @input Exact-head DateInput stories across field states, presentations,+ * themes, direction, pointers, and viewport sizes+ * @output Screenshots and fail-closed sensor receipts for the DateInput+ * whole-component audit+ * @position Component-owned Night Watch browser evidence; CI runs it only for a+ * DateInput audit pull request+ */++import {createHash} from 'node:crypto';+import {execFileSync} from 'node:child_process';+import * as fs from 'node:fs';+import * as path from 'node:path';+import {expect, test, type Locator, type Page} from '@playwright/test';+import {holdMotionStill} from '@astryxdesign/a11y-spec/chromium';+import {+ DEFAULT_STORYBOOK_DIR,+ serveStorybook,+ type StaticServer,+} from '@astryxdesign/a11y-spec/storybook';++const OUTPUT = path.resolve('date-input-audit-evidence');+const WIDE = {width: 1024, height: 768};+const NARROW = {width: 320, height: 720};++type Mode = 'light' | 'dark';+type Direction = 'ltr' | 'rtl';+type Theme = 'neutral' | 'butter';+type Pointer = 'fine' | 'coarse';+type Story =+ | 'default'+ | 'with-value'+ | 'disabled'+ | 'disabled-with-message'+ | 'with-error-status'+ | 'with-warning-status'+ | 'with-success-status'+ | 'clearable'+ | 'open-calendar-audit'+ | 'styling-parts';+type State =+ | 'rest'+ | 'hover'+ | 'focus-toggle'+ | 'focus-input'+ | 'typed-invalid'+ | 'clear-hover'+ | 'open'+ | 'sheet-open';+type Surface = 'popover' | 'native' | 'sheet' | 'mixed';++type AuditCase = {+ key: string;+ story: Story;+ args: Record<string, string>;+ surface: Surface;+ mode: Mode;+ direction: Direction;+ theme: Theme;+ state: State;+ pointer: Pointer;+ forcedColors: boolean;+ viewport: {width: number; height: number};+};++type AuditReceipt = {+ passed: boolean;+ expected: Record<string, unknown>;+};++const cases: AuditCase[] = [];+function addPair(+ key: string,+ options: Partial<Omit<AuditCase, 'key' | 'mode'>> = {},+) {+ for (const mode of ['light', 'dark'] as const) {+ cases.push({+ key: `${key}-${mode}`,+ story: options.story ?? 'with-value',+ args: options.args ?? {},+ surface: options.surface ?? 'popover',+ mode,+ direction: options.direction ?? 'ltr',+ theme: options.theme ?? 'neutral',+ state: options.state ?? 'rest',+ pointer: options.pointer ?? 'fine',+ forcedColors: options.forcedColors ?? false,+ viewport: options.viewport ?? WIDE,+ });+ }+}++const BUSY = {isLoading: '!true'};++addPair('empty-rest', {story: 'default'});+addPair('valued-rest');+addPair('valued-hover', {state: 'hover'});+addPair('focus-toggle', {state: 'focus-toggle'});+addPair('focus-input', {state: 'focus-input'});+addPair('typed-invalid', {state: 'typed-invalid'});+addPair('open-calendar', {story: 'open-calendar-audit', state: 'open'});+addPair('size-sm', {args: {size: 'sm'}});+addPair('size-lg', {args: {size: 'lg'}});+addPair('busy-rest', {args: BUSY});+addPair('busy-hover', {args: BUSY, state: 'hover'});+addPair('busy-focus-input', {args: BUSY, state: 'focus-input'});+addPair('disabled-rest', {story: 'disabled'});+addPair('disabled-hover', {story: 'disabled', state: 'hover'});+addPair('disabled-focus-input', {story: 'disabled', state: 'focus-input'});+addPair('disabled-message-focus', {+ story: 'disabled-with-message',+ state: 'focus-toggle',+});+addPair('status-error', {story: 'with-error-status'});+addPair('status-warning', {story: 'with-warning-status'});+addPair('status-success', {story: 'with-success-status'});+addPair('clearable-rest', {story: 'clearable'});+addPair('clearable-hover-clear', {story: 'clearable', state: 'clear-hover'});+addPair('native-rest', {args: {presentation: 'native'}, surface: 'native'});+addPair('native-busy', {+ args: {presentation: 'native', ...BUSY},+ surface: 'native',+});+addPair('sheet-rest', {+ args: {presentation: 'bottom-sheet'},+ surface: 'sheet',+});+addPair('sheet-busy', {+ args: {presentation: 'bottom-sheet', ...BUSY},+ surface: 'sheet',+});+addPair('styling-parts', {story: 'styling-parts', surface: 'mixed'});+addPair('custom-theme-rest', {theme: 'butter'});+addPair('custom-theme-busy', {theme: 'butter', args: BUSY});+addPair('custom-theme-disabled', {theme: 'butter', story: 'disabled'});+addPair('custom-theme-open', {+ theme: 'butter',+ story: 'open-calendar-audit',+ state: 'open',+});+addPair('rtl-clearable', {story: 'clearable', direction: 'rtl'});+addPair('rtl-open', {+ story: 'open-calendar-audit',+ state: 'open',+ direction: 'rtl',+});+addPair('narrow-fine', {viewport: NARROW});+addPair('narrow-coarse-native', {+ viewport: NARROW,+ pointer: 'coarse',+ surface: 'native',+});+addPair('narrow-coarse-sheet-open', {+ viewport: NARROW,+ pointer: 'coarse',+ surface: 'sheet',+ args: {presentation: 'adaptive-bottom-sheet'},+ state: 'sheet-open',+});+addPair('forced-colors-focus-input', {+ state: 'focus-input',+ forcedColors: true,+});++/** Accessible name each story gives its field. */+const LABEL: Record<Story, string | null> = {+ default: 'Date',+ 'with-value': 'Event date',+ disabled: 'Locked date',+ 'disabled-with-message': 'Event date',+ 'with-error-status': 'Event date',+ 'with-warning-status': 'Meeting date',+ 'with-success-status': 'Appointment date',+ clearable: 'Event date',+ 'open-calendar-audit': 'Appointment date',+ 'styling-parts': null,+};++// Default mode, so a failing case does not skip the rest of the matrix.+test.describe.configure({retries: 0});+let server: StaticServer;+let checkoutSha: string;+let storybookSha: string;++function storyId(item: AuditCase) {+ return `core-dateinput--${item.story}`;+}++function storyUrl(item: AuditCase) {+ const args = Object.entries(item.args)+ .map(([name, value]) => `${name}:${value}`)+ .join(';');+ return `${server.origin}/iframe.html?id=${storyId(item)}&viewMode=story${+ args ? `&args=${args}` : ''+ }&globals=colorMode:${item.mode};astryxTheme:${item.theme};direction:${item.direction}`;+}++function isBusyCase(item: AuditCase) {+ return item.args.isLoading === '!true';+}++function isDisabledCase(item: AuditCase) {+ return item.story === 'disabled' || item.story === 'disabled-with-message';+}++async function settle(page: Page) {+ await holdMotionStill(page);+ await page.evaluate(async () => document.fonts.ready);+ await page.waitForTimeout(40);+}++/** The element that carries the field's name and value on this surface. */+function fieldControl(page: Page, item: AuditCase): Locator {+ return item.surface === 'native'+ ? page.locator('#storybook-root input[type="date"]').first()+ : page.locator('#storybook-root [role="combobox"]').first();+}++test.beforeAll(async () => {+ // Never wipe: Playwright restarts the worker after a failing case and+ // reruns this hook, which would delete frames already banked.+ fs.mkdirSync(OUTPUT, {recursive: true});+ checkoutSha = execFileSync('git', ['rev-parse', 'HEAD'], {+ encoding: 'utf8',+ }).trim();+ const expected = process.env.ASTRYX_HEAD_SHA;+ if (expected && expected !== checkoutSha) {+ throw new Error(+ `checkout ${checkoutSha} does not match expected head ${expected}`,+ );+ }+ server = await serveStorybook(+ process.env.ASTRYX_STORYBOOK_DIR ?? DEFAULT_STORYBOOK_DIR,+ );+ const response = await fetch(`${server.origin}/astryx-build-sha.txt`);+ if (!response.ok) {+ throw new Error(`Storybook build has no SHA stamp (${response.status})`);+ }+ storybookSha = (await response.text()).trim();+ if (storybookSha !== checkoutSha) {+ throw new Error(+ `Storybook ${storybookSha} does not match checkout ${checkoutSha}`,+ );+ }+});++test.afterAll(async () => {+ await server?.close();+});++for (const item of cases) {+ test(item.key, async ({browser}) => {+ const context = await browser.newContext({+ viewport: item.viewport,+ colorScheme: item.mode,+ reducedMotion: 'reduce',+ hasTouch: item.pointer === 'coarse',+ forcedColors: item.forcedColors ? 'active' : 'none',+ });+ const page = await context.newPage();+ const pageErrors: string[] = [];+ page.on('pageerror', error => pageErrors.push(String(error)));+ await page.goto(storyUrl(item), {waitUntil: 'load'});+ await page.locator('#storybook-root').waitFor();+ await expect(+ page.locator('#storybook-root .astryx-date-input').first(),+ ).toBeVisible();++ const wrapper = page.locator('#storybook-root .astryx-date-input').first();+ const control = fieldControl(page, item);+ const label = LABEL[item.story];+ if (item.surface !== 'mixed') {+ await expect(control).toBeVisible();+ if (label != null) {+ await expect(control).toHaveAccessibleName(label);+ }+ }+ await settle(page);++ // The calendar toggle is the field's first button; its name follows the+ // open state.+ const toggle = wrapper.locator('button').first();+ if (item.state === 'hover') {+ await wrapper.hover();+ } else if (item.state === 'focus-toggle') {+ await page.locator('body').focus();+ await page.keyboard.press('Tab');+ if (item.story === 'disabled-with-message') {+ // The reason tooltip opens after its show delay.+ await page.waitForTimeout(800);+ }+ } else if (item.state === 'focus-input') {+ await control.focus();+ // Keyboard modality: a key press after programmatic focus.+ await page.keyboard.press('Shift');+ } else if (item.state === 'typed-invalid') {+ await control.focus();+ await page.keyboard.press('ControlOrMeta+a');+ await page.keyboard.type('not a date');+ } else if (item.state === 'clear-hover') {+ await wrapper.getByRole('button', {name: 'Clear Event date'}).hover();+ await page.waitForTimeout(800);+ } else if (item.state === 'open') {+ await expect(control).toHaveAttribute('aria-expanded', 'true');+ await expect(page.getByRole('dialog').first()).toBeVisible();+ } else if (item.state === 'sheet-open') {+ await control.tap();+ await expect(page.getByRole('dialog').first()).toBeVisible();+ await page.waitForTimeout(120);+ }+ await page.evaluate(async () => document.fonts.ready);+ await page.waitForTimeout(40);++ const observed = await page.evaluate(() => ({+ theme: document+ .querySelector('[data-astryx-theme]')+ ?.getAttribute('data-astryx-theme'),+ mode: document.documentElement.getAttribute('data-theme'),+ direction: getComputedStyle(+ document.querySelector('.astryx-date-input') as HTMLElement,+ ).direction,+ viewport: {width: innerWidth, height: innerHeight},+ reducedMotion: matchMedia('(prefers-reduced-motion: reduce)').matches,+ coarsePointer: matchMedia('(pointer: coarse)').matches,+ hoverCapable: matchMedia('(hover: hover)').matches,+ forcedColors: matchMedia('(forced-colors: active)').matches,+ horizontalOverflow: document.documentElement.scrollWidth > innerWidth + 1,+ fonts: document.fonts.status,+ activeElement: (() => {+ const active = document.activeElement as HTMLElement | null;+ if (active == null || active === document.body) {+ return null;+ }+ return {+ tag: active.tagName.toLowerCase(),+ type: active.getAttribute('type'),+ role: active.getAttribute('role'),+ label: active.getAttribute('aria-label'),+ focusVisible: active.matches(':focus-visible'),+ outlineStyle: getComputedStyle(active).outlineStyle,+ outlineColor: getComputedStyle(active).outlineColor,+ };+ })(),+ // Top-layer popovers have no offsetParent, and BottomSheet is a native+ // <dialog> without an explicit role, so read rendered visibility and+ // both dialog forms.+ tooltips: Array.from(document.querySelectorAll('[role="tooltip"]'))+ .filter(node => node.checkVisibility())+ .map(node => node.textContent?.replace(/\s+/g, ' ').trim()),+ dialogs: Array.from(+ new Set(document.querySelectorAll('[role="dialog"], dialog[open]')),+ )+ .filter(node => node.checkVisibility())+ .map(+ node =>+ node.getAttribute('aria-label') ??+ document+ .getElementById(node.getAttribute('aria-labelledby') ?? '')+ ?.textContent?.trim() ??+ null,+ ),+ }));+ const paint = await wrapper.evaluate(element => {+ const style = getComputedStyle(element);+ const box = element.getBoundingClientRect();+ return {+ hovered: element.matches(':hover'),+ opacity: style.opacity,+ boxShadow: style.boxShadow,+ borderColor: style.borderTopColor,+ backgroundColor: style.backgroundColor,+ cursor: style.cursor,+ themeSize: element.getAttribute('data-size'),+ themeStatus: element.getAttribute('data-status'),+ themeDisabled: element.getAttribute('data-disabled'),+ spinners: element.querySelectorAll('[class*="astryx-spinner"]').length,+ geometry: {x: box.x, y: box.y, width: box.width, height: box.height},+ };+ });+ const semantics =+ item.surface === 'mixed'+ ? null+ : await control.evaluate(element => ({+ tag: element.tagName.toLowerCase(),+ type: element.getAttribute('type'),+ role: element.getAttribute('role'),+ disabledAttribute: element.hasAttribute('disabled'),+ ariaDisabled: element.getAttribute('aria-disabled'),+ ariaBusy: element.getAttribute('aria-busy'),+ ariaInvalid: element.getAttribute('aria-invalid'),+ ariaExpanded: element.getAttribute('aria-expanded'),+ readOnly: (element as HTMLInputElement).readOnly,+ focused: element === document.activeElement,+ value: (element as HTMLInputElement).value,+ alertText:+ element+ .closest('.astryx-date-input')+ ?.querySelector('[role="alert"]')+ ?.textContent?.trim() ?? null,+ }));+ const toggleState =+ item.surface === 'popover'+ ? await toggle.evaluate(element => ({+ disabledAttribute: element.hasAttribute('disabled'),+ ariaDisabled: element.getAttribute('aria-disabled'),+ tabIndex: (element as HTMLButtonElement).tabIndex,+ }))+ : null;++ const busy = isBusyCase(item);+ const disabled = isDisabledCase(item);+ let semanticsPass = true;+ if (semantics != null) {+ semanticsPass =+ semantics.disabledAttribute === false &&+ (busy ? semantics.ariaBusy === 'true' : semantics.ariaBusy === null) &&+ (busy || disabled+ ? semantics.ariaDisabled === 'true'+ : semantics.ariaDisabled === null) &&+ (item.surface === 'native'+ ? semantics.tag === 'input' && semantics.type === 'date'+ : semantics.role === 'combobox') &&+ (toggleState == null || toggleState.disabledAttribute === false);+ }++ // Expectations authored from current authority before observation:+ // spec:AST-085 FR1 (focusable, no native disabled), FR6 (disabled paint+ // belongs to the disabled state; busy keeps its pending treatment; no+ // hover affordance while disabled; keyboard focus indicator remains), and+ // family:buttons FR4 (disabled and pending styling stay distinct).+ let statePass = true;+ if (busy) {+ statePass = statePass && paint.opacity === '1' && paint.spinners >= 1;+ }+ if (disabled) {+ statePass =+ statePass &&+ paint.opacity !== '1' &&+ paint.themeDisabled === 'disabled';+ }+ if (item.state === 'hover') {+ statePass = statePass && paint.hovered;+ if (disabled || busy) {+ statePass = statePass && paint.boxShadow === 'none';+ }+ } else if (item.state === 'focus-input') {+ // Forced colors replaces box shadows; the receipt still records the+ // forced border and outline colors for review.+ statePass =+ statePass &&+ semantics?.focused === true &&+ (item.forcedColors || paint.boxShadow !== 'none');+ } else if (item.state === 'focus-toggle') {+ statePass =+ statePass &&+ observed.activeElement?.tag === 'button' &&+ observed.activeElement.focusVisible &&+ observed.activeElement.outlineStyle !== 'none';+ if (item.story === 'disabled-with-message') {+ statePass =+ statePass &&+ observed.tooltips.includes('You need the Editor role to change this');+ }+ } else if (item.state === 'typed-invalid') {+ statePass =+ statePass &&+ semantics?.value === 'not a date' &&+ semantics.ariaInvalid === 'true' &&+ (semantics.alertText ?? '').length > 0;+ } else if (item.state === 'open') {+ statePass =+ statePass &&+ semantics?.ariaExpanded === 'true' &&+ observed.dialogs.length === 1;+ } else if (item.state === 'sheet-open') {+ statePass =+ statePass &&+ semantics?.ariaExpanded === 'true' &&+ observed.dialogs.length >= 1;+ }++ const png = await page.screenshot({animations: 'disabled', fullPage: true});+ const image = `${item.key}.png`;+ const receipt = {+ schemaVersion: 2,+ expected: {+ build: checkoutSha,+ storyId: storyId(item),+ args: item.args,+ surface: item.surface,+ mode: item.mode,+ direction: item.direction,+ theme: item.theme,+ state: item.state,+ pointer: item.pointer,+ forcedColors: item.forcedColors,+ viewport: item.viewport,+ label,+ busy,+ disabled,+ },+ observed: {+ build: storybookSha,+ ...observed,+ paint,+ semantics,+ toggleState,+ pageErrors,+ },+ image: {+ file: image,+ sha256: createHash('sha256').update(png).digest('hex'),+ width: png.readUInt32BE(16),+ height: png.readUInt32BE(20),+ },+ checks: {semanticsPass, statePass},+ passed:+ storybookSha === checkoutSha &&+ pageErrors.length === 0 &&+ observed.theme === item.theme &&+ observed.mode === item.mode &&+ observed.direction === item.direction &&+ observed.viewport.width === item.viewport.width &&+ observed.viewport.height === item.viewport.height &&+ observed.reducedMotion &&+ observed.coarsePointer === (item.pointer === 'coarse') &&+ observed.forcedColors === item.forcedColors &&+ !observed.horizontalOverflow &&+ observed.fonts === 'loaded' &&+ semanticsPass &&+ statePass,+ };+ fs.writeFileSync(path.join(OUTPUT, image), png);+ fs.writeFileSync(+ path.join(OUTPUT, `${item.key}.sensors.json`),+ `${JSON.stringify(receipt, null, 2)}\n`,+ );++ await context.close();+ });+}++test('manifest is complete', async () => {+ const receiptFiles = fs+ .readdirSync(OUTPUT)+ .filter(file => file.endsWith('.sensors.json'));+ const receipts = receiptFiles.map(+ (file): AuditReceipt =>+ JSON.parse(+ fs.readFileSync(path.join(OUTPUT, file), 'utf8'),+ ) as AuditReceipt,+ );+ const manifest = {+ schemaVersion: 2,+ component: 'core/DateInput',+ build: checkoutSha,+ frames: cases.map(item => ({+ key: item.key,+ image: `${item.key}.png`,+ receipt: `${item.key}.sensors.json`,+ })),+ };+ fs.writeFileSync(+ path.join(OUTPUT, 'manifest.json'),+ `${JSON.stringify(manifest, null, 2)}\n`,+ );+ expect(receiptFiles).toHaveLength(cases.length);+ expect(+ receipts+ .filter(receipt => !receipt.passed)+ .map(receipt => receipt.expected),+ ).toEqual([]);+});diff --git a/packages/core/src/DateInput/tokens.stylex.ts b/packages/core/src/DateInput/tokens.stylex.tsindex 47ca2b193e..7452a0475f 100644--- a/packages/core/src/DateInput/tokens.stylex.ts+++ b/packages/core/src/DateInput/tokens.stylex.ts@@ -4,7 +4,9 @@* @file tokens.stylex.ts* @input StyleX variable and constant definitions* @output Exports DateInput layout constants and derived geometry- * @position Lab component tokens consumed by DateInput.tsx, MonthScroller.tsx, Wheel.tsx, MonthYearWheels.tsx+ * @position Core touch-picker geometry consumed by the DateInput touch surface+ * (TouchDateField, MonthScroller, Wheel, MonthYearWheels) and by the+ * DateTimeInput and TimeInput touch fields** The picker's whole geometry derives from two numbers, which is what makes* the fixed height and the scroll snapping exact: