Skip to content

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

TypeScript

fix(DateInput, DateRangeInput): silence the busy Spinner and announce the busy start once (#7939)

Cindy Zhanga732e5c64815
diff --git a/.changeset/date-inputs-busy-announces-once.md b/.changeset/date-inputs-busy-announces-once.md
new file mode 100644
index 0000000000..154c9f3168
--- /dev/null
+++ b/.changeset/date-inputs-busy-announces-once.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] `DateInput` (popover, native and bottom-sheet presentations) and `DateRangeInput` announce their busy start ("Loading") once, politely, through the shared announcement channel, and the Spinner they show while busy is hidden from assistive technology (`spec:AST-086` FR6, FR8). Before, that Spinner mounted as its own `role="status"` region already named "Loading", which screen readers often skip, and it was a second owner beside the field's `aria-busy`. Inside an open modal dialog the announcement goes to a status region in the dialog. Tests that found the busy Spinner with `getByRole('status', {name: 'Loading'})` should check the field's `aria-busy` instead.
+
+@cixzhang
diff --git a/packages/core/locales/en.json b/packages/core/locales/en.json
index d8e2bea405..a3aa68558d 100644
--- a/packages/core/locales/en.json
+++ b/packages/core/locales/en.json
@@ -1169,7 +1169,7 @@
},
"@astryx.spinner.loading": {
"defaultMessage": "Loading",
- "description": "Screen-reader-only default name for a standalone Spinner's role=\"status\" element, used when the consumer supplies neither `aria-label` nor a visible string label; also announced once when a busy field or selector (TextInput, TextArea, Selector, MultiSelector, ComplexSelector) starts loading, in place of its decorative Spinner. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge."
+ "description": "Screen-reader-only default name for a standalone Spinner's role=\"status\" element, used when the consumer supplies neither `aria-label` nor a visible string label; also announced once when a busy input or selector starts loading, in place of its decorative Spinner. Present-progressive form. Kept separate from `button.loading` and `typeahead.loading` — translations may diverge."
},
"@astryx.chatComposerDrawer.expand": {
"defaultMessage": "Expand {label}",
diff --git a/packages/core/src/DateInput/DateInput.tsx b/packages/core/src/DateInput/DateInput.tsx
index 0a92096f50..b3c1706b3d 100644
--- a/packages/core/src/DateInput/DateInput.tsx
+++ b/packages/core/src/DateInput/DateInput.tsx
@@ -57,6 +57,7 @@ import {
} from '../Calendar';
import {useCalendarConstraints} from '../Calendar/hooks';
import {useInputStatusIcon} from '../hooks/useInputStatusIcon';
+import {useBusyAnnouncement} from '../hooks/useBusyAnnouncement';
import {useMediaQuery} from '../hooks/useMediaQuery';
import {useResolvedRequired} from '../hooks/useResolvedRequired';
import {usePopover} from '../Popover';
@@ -547,6 +548,9 @@ function PointerDateField({
const [, startTransition] = useTransition();
const [optimisticValue, setOptimisticValue] = useOptimistic(value);
const isBusy = isLoading || optimisticValue !== value;
+ // The busy Spinner is decorative; this control announces its busy start
+ // (spec:AST-086 FR8).
+ useBusyAnnouncement(isBusy, t('@astryx.spinner.loading'), inputRef);
const isEffectivelyDisabled = isDisabled || isBusy;
// A disabled or busy field never renders native `disabled` (spec:AST-085
@@ -932,7 +936,7 @@ function PointerDateField({
onClick={handleClear}
/>
)}
- {isBusy && <Spinner size="sm" />}
+ {isBusy && <Spinner size="sm" aria-hidden="true" />}
{statusIcon}
{popover.render(
<Calendar
diff --git a/packages/core/src/DateInput/DateInputTouch.test.tsx b/packages/core/src/DateInput/DateInputTouch.test.tsx
index d4f6227152..b27ba2af51 100644
--- a/packages/core/src/DateInput/DateInputTouch.test.tsx
+++ b/packages/core/src/DateInput/DateInputTouch.test.tsx
@@ -666,6 +666,51 @@ describe('DateInput — field parity', () => {
resolve();
});
+ it('announces a busy start from a pick inside the open sheet, not behind it (spec:AST-086 FR8, Platform support)', async () => {
+ // The stubbed showModal() opens the dialog but jsdom cannot match
+ // `:modal`; stand in for the sheet the browser presents modally.
+ const matches = Element.prototype.matches;
+ const modalSpy = vi
+ .spyOn(Element.prototype, 'matches')
+ .mockImplementation(function (this: Element, selector: string) {
+ return selector === ':modal'
+ ? this instanceof HTMLDialogElement && this.open
+ : matches.call(this, selector);
+ });
+ const changeAction = vi.fn(async () => new Promise<void>(() => {}));
+ withLayout(() => {
+ render(
+ <DateInput
+ nativePicker="never"
+ label="Ship date"
+ value="2026-03-10"
+ min="2026-03-01"
+ max="2026-03-31"
+ onChange={() => {}}
+ changeAction={changeAction}
+ />,
+ );
+ fireEvent.click(field());
+ fireEvent.click(
+ within(pane('March 2026')).getByRole('button', {
+ name: /March 25, 2026/,
+ }),
+ );
+ });
+ const sheet = document.querySelector('dialog[open]');
+ expect(sheet).not.toBeNull();
+ await waitFor(() => {
+ expect(
+ sheet!.querySelector('[data-astryx-modal-busy-region]'),
+ ).toHaveTextContent('Loading');
+ });
+ expect(
+ document.querySelector('[data-astryx-live-region="polite"]')
+ ?.textContent ?? '',
+ ).toBe('');
+ modalSpy.mockRestore();
+ });
+
it('drops the Field wrapper inside an InputGroup', () => {
render(
<InputGroup label="Range">
diff --git a/packages/core/src/DateInput/NativeDateField.test.tsx b/packages/core/src/DateInput/NativeDateField.test.tsx
index 8f718109cb..1b50c39107 100644
--- a/packages/core/src/DateInput/NativeDateField.test.tsx
+++ b/packages/core/src/DateInput/NativeDateField.test.tsx
@@ -222,7 +222,11 @@ describe('DateInput nativePicker', () => {
expect(changeAction).toHaveBeenCalledExactlyOnceWith('2026-03-21');
expect(getInput()).not.toBeDisabled();
expect(getInput()).toHaveAttribute('aria-busy', 'true');
- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();
+ // The busy Spinner is decorative (spec:AST-086 FR8).
+ expect(document.querySelector('.astryx-spinner')).toHaveAttribute(
+ 'aria-hidden',
+ 'true',
+ );
expect(screen.getByText('March 21, 2026')).toBeInTheDocument();
fireEvent.change(getInput(), {target: {value: '2026-03-22'}});
@@ -597,7 +601,11 @@ describe('DateInput nativePicker', () => {
expect(calls).toEqual(['onChange', 'changeAction']);
expect(changeAction).toHaveBeenCalledExactlyOnceWith(undefined);
- expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();
+ // The busy Spinner is decorative (spec:AST-086 FR8).
+ expect(document.querySelector('.astryx-spinner')).toHaveAttribute(
+ 'aria-hidden',
+ 'true',
+ );
await act(async () => resolveAction());
});
diff --git a/packages/core/src/DateInput/NativeDateField.tsx b/packages/core/src/DateInput/NativeDateField.tsx
index f47bf91e77..42afa51e42 100644
--- a/packages/core/src/DateInput/NativeDateField.tsx
+++ b/packages/core/src/DateInput/NativeDateField.tsx
@@ -49,6 +49,7 @@ import {
} from '../Field';
import {useInputStatusIcon, useMergedRefs} from '../hooks';
import {useMediaQuery} from '../hooks/useMediaQuery';
+import {useBusyAnnouncement} from '../hooks/useBusyAnnouncement';
import {useResolvedRequired} from '../hooks/useResolvedRequired';
import {Icon} from '../Icon';
import {useLocale, useTranslator} from '../i18n';
@@ -328,6 +329,9 @@ export function NativeDateField({
const [, startTransition] = useTransition();
const [optimisticValue, setOptimisticValue] = useOptimistic(value);
const isBusy = isLoading || optimisticValue !== value;
+ // The busy Spinner is decorative; this control announces its busy start
+ // (spec:AST-086 FR8).
+ useBusyAnnouncement(isBusy, t('@astryx.spinner.loading'), inputRef);
// Keep the OS picker mounted and focusable while its own Action is pending.
// Native TimeInput follows the same pattern: commit guards block duplicates,
// while aria-busy and the Spinner communicate the save without detaching the
@@ -687,7 +691,7 @@ export function NativeDateField({
onClick={handleClear}
/>
)}
- {isBusy && <Spinner size="sm" />}
+ {isBusy && <Spinner size="sm" aria-hidden="true" />}
{statusIcon}
{showsDisabledMessage &&
disabledMessageTooltip.renderTooltip(disabledMessage)}
diff --git a/packages/core/src/DateInput/TouchDateField.tsx b/packages/core/src/DateInput/TouchDateField.tsx
index 553ce13601..49b9cf3f30 100644
--- a/packages/core/src/DateInput/TouchDateField.tsx
+++ b/packages/core/src/DateInput/TouchDateField.tsx
@@ -73,6 +73,7 @@ import {
} from '../Field';
import {useInputStatusIcon, useMergedRefs} from '../hooks';
import {useResolvedRequired} from '../hooks/useResolvedRequired';
+import {useBusyAnnouncement} from '../hooks/useBusyAnnouncement';
import {Icon} from '../Icon';
import {IconButton} from '../IconButton';
import {useLocale, useTranslator} from '../i18n';
@@ -665,6 +666,15 @@ export function TouchDateField({
);
const [isSheetOpen, setIsSheetOpen] = useState(false);
+ const sheetBodyRef = useRef<HTMLDivElement | null>(null);
+ // The busy Spinner is decorative; this control announces its busy start
+ // (spec:AST-086 FR8). A date picked under a pending changeAction starts it
+ // while the modal sheet is open, so it is announced from inside the sheet.
+ useBusyAnnouncement(
+ isBusy,
+ t('@astryx.spinner.loading'),
+ isSheetOpen ? sheetBodyRef : inputRef,
+ );
const [isWheelOpen, setIsWheelOpen] = useState(false);
const scrollerHandleRef = useRef<MonthScrollerHandle | null>(null);
// Pending focus handoff from the clear button; see handleClear.
@@ -1303,7 +1313,7 @@ export function TouchDateField({
onClick={handleClear}
/>
)}
- {isBusy && <Spinner size="sm" />}
+ {isBusy && <Spinner size="sm" aria-hidden="true" />}
{statusIcon}
<BottomSheet
isOpen={isSheetOpen}
@@ -1314,7 +1324,9 @@ export function TouchDateField({
height="hug"
// sheetBody owns the inset, including the band under the grab handle.
padding={0}>
- <div {...stylex.props(styles.sheetBody)}>{surface}</div>
+ <div ref={sheetBodyRef} {...stylex.props(styles.sheetBody)}>
+ {surface}
+ </div>
</BottomSheet>
{showsDisabledMessage &&
disabledMessageTooltip.renderTooltip(disabledMessage)}
diff --git a/packages/core/src/DateRangeInput/DateRangeInput.tsx b/packages/core/src/DateRangeInput/DateRangeInput.tsx
index 127968684b..ee3bac7e41 100644
--- a/packages/core/src/DateRangeInput/DateRangeInput.tsx
+++ b/packages/core/src/DateRangeInput/DateRangeInput.tsx
@@ -75,6 +75,7 @@ import {
import type {SizeValue} from '../utils/types';
import {useSize} from '../SizeContext/SizeContext';
import {useInputStatusIcon} from '../hooks/useInputStatusIcon';
+import {useBusyAnnouncement} from '../hooks/useBusyAnnouncement';
import {useMergedRefs} from '../hooks/useMergedRefs';
import {useResolvedRequired} from '../hooks/useResolvedRequired';
import {themeProps} from '../utils/themeProps';
@@ -645,6 +646,9 @@ export function DateRangeInput({
);
const triggerRef = useRef<HTMLButtonElement>(null);
+ // The busy Spinner is decorative; this control announces its busy start
+ // (spec:AST-086 FR8).
+ useBusyAnnouncement(isBusy, t('@astryx.spinner.loading'), triggerRef);
const triggerButtonRef = useMergedRefs<HTMLButtonElement>(triggerRef, ref);
const handleClear = useCallback(
@@ -787,7 +791,7 @@ export function DateRangeInput({
{ariaLabelProp ?? triggerAriaLabel}
</VisuallyHidden>
)}
- {isBusy && <Spinner size="sm" />}
+ {isBusy && <Spinner size="sm" aria-hidden="true" />}
{statusIcon}
</div>
{isEffectivelyRequired && (
diff --git a/packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx b/packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx
index 7284d0cc08..0b185e53ba 100644
--- a/packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx
+++ b/packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx
@@ -9,13 +9,24 @@
*/
import {StrictMode, useEffect, useRef, type ReactElement} from 'react';
-import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
+import {
+ afterAll,
+ afterEach,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ it,
+ vi,
+} from 'vitest';
import {act, fireEvent, render, screen} from '@testing-library/react';
import {TextInput} from '../TextInput';
import {TextArea} from '../TextArea';
import {Selector} from '../Selector';
import {MultiSelector} from '../MultiSelector';
import {ComplexSelector} from '../ComplexSelector';
+import {DateInput} from '../DateInput';
+import {DateRangeInput} from '../DateRangeInput';
import {BaseTypeahead, Typeahead} from '../Typeahead';
import type {SearchableItem, SearchSource} from '../Typeahead';
import {Tokenizer} from '../Tokenizer';
@@ -79,6 +90,31 @@ const OWNERS: ReadonlyArray<
/>
),
],
+ ...(['popover', 'native', 'bottom-sheet'] as const).map(
+ presentation =>
+ [
+ `DateInput (${presentation})`,
+ (isLoading: boolean) => (
+ <DateInput
+ label="Date"
+ presentation={presentation}
+ onChange={() => {}}
+ isLoading={isLoading}
+ />
+ ),
+ ] as const,
+ ),
+ [
+ 'DateRangeInput',
+ isLoading => (
+ <DateRangeInput
+ label="Dates"
+ value={null}
+ onChange={() => {}}
+ isLoading={isLoading}
+ />
+ ),
+ ],
[
'ComplexSelector',
isLoading => (
@@ -138,6 +174,21 @@ const SEARCH_OWNERS: ReadonlyArray<
],
];
+// The bottom-sheet DateInput measures its sheet; jsdom has no ResizeObserver.
+beforeAll(() => {
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ },
+ );
+});
+afterAll(() => {
+ vi.unstubAllGlobals();
+});
+
/** Calls that announced the busy start, ignoring each control's other messages. */
function busyAnnouncements() {
return announce.mock.calls.filter(([message]) => message === 'Loading');