Skip to content

Commit a261602

Browse files
committed
fix(Spinner): isolate standalone progress announcements from busy consumers
1 parent 6d105d4 commit a261602

44 files changed

Lines changed: 222 additions & 572 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.changeset/spinner-shared-announcement.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
'@astryxdesign/core': patch
33
---
44

5-
[fix] Route standalone Spinner labels through the shared polite announcement channel once per appearance or label change, rather than mounting a status region with its name. Rerenders and StrictMode replay do not repeat the channel call; a new appearance with the same words does. Keep package-owned composed indicators silent and visible labels readable. Spinner's ring now exposes `role="img"` instead of `role="status"`; update tests that query a standalone Spinner by its old role. Default sizing, animation, and label naming are unchanged.
5+
[fix] Route standalone Spinner labels through the shared polite announcement channel once per appearance or label change, rather than mounting a status region with its name. Rerenders and StrictMode replay do not repeat the channel call; a new appearance with the same words does. Spinner's ring now exposes an indeterminate `role="progressbar"` instead of `role="status"`, without a fabricated `aria-valuenow`. Update tests that query a standalone Spinner by its old role. Visible labels, sizing, animation, and label naming are unchanged.
66
@korkt-kim

‎apps/storybook/stories/Spinner.stories.tsx‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
// Copyright (c) Meta Platforms, Inc. and affiliates.
22

3-
/**
4-
* @file Spinner.stories.tsx
5-
* @input Spinner, React state, and theme fixtures
6-
* @output Spinner examples and a repeatable conditional-announcement scenario
7-
* @position Storybook visual and assistive-technology verification surface
8-
*/
9-
10-
import {StrictMode, useState, type CSSProperties} from 'react';
3+
import type {CSSProperties} from 'react';
114
import type {Meta, StoryObj} from '@storybook/react';
125
import {Spinner} from '@astryxdesign/core/Spinner';
13-
import {Button} from '@astryxdesign/core/Button';
146
import {Text} from '@astryxdesign/core/Text';
157
import {HStack, VStack} from '@astryxdesign/core/Layout';
168
import {Theme, defineTheme} from '@astryxdesign/core/theme';
@@ -57,31 +49,6 @@ export const Default: Story = {
5749
},
5850
};
5951

60-
export const ConditionalAppearance: Story = {
61-
render: function ConditionalAppearance() {
62-
const [isLoading, setIsLoading] = useState(false);
63-
const [renderCount, setRenderCount] = useState(0);
64-
return (
65-
<StrictMode>
66-
<VStack gap={4}>
67-
<HStack gap={2}>
68-
<Button
69-
label={isLoading ? 'Finish loading' : 'Start loading'}
70-
onClick={() => setIsLoading(value => !value)}
71-
/>
72-
<Button
73-
label="Rerender"
74-
onClick={() => setRenderCount(value => value + 1)}
75-
/>
76-
</HStack>
77-
<Text>Rerenders: {renderCount}</Text>
78-
{isLoading && <Spinner label="Loading results" />}
79-
</VStack>
80-
</StrictMode>
81-
);
82-
},
83-
};
84-
8552
export const Sizes: Story = {
8653
render: () => (
8754
<HStack gap={4} vAlign="center">

‎packages/core/src/Chat/ChatMessageList.test.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @file ChatMessageList.test.tsx
55
* @input React Testing Library, Vitest, and the public ChatMessageList surface
6-
* @output Observable log, empty-state, alignment, and non-live loading-indicator regressions
6+
* @output Observable log, empty-state, alignment, and async-loading regressions
77
* @position Colocated component behavior tests
88
*/
99

@@ -182,10 +182,9 @@ describe('ChatMessageList', () => {
182182
);
183183
});
184184
expect(action).toHaveBeenCalledTimes(1);
185-
expect(screen.getByRole('img', {name: 'Loading'})).toBeTruthy();
186-
expect(screen.queryByRole('status', {name: 'Loading'})).toBeNull();
185+
expect(screen.getByRole('status', {name: 'Loading'})).toBeTruthy();
187186
await act(async () => complete());
188-
expect(screen.queryByRole('img', {name: 'Loading'})).toBeNull();
187+
expect(screen.queryByRole('status', {name: 'Loading'})).toBeNull();
189188
unmount();
190189
expect(disconnect).toHaveBeenCalledTimes(1);
191190
} finally {

‎packages/core/src/CheckboxInput/CheckboxInput.tsx‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/**
66
* @file CheckboxInput.tsx
7-
* Composes a silent Spinner; the checkbox owns busy feedback.
87
* @input Uses React, useId, ChangeEvent, FieldLabel, FieldStatus, IconType, InputStatus, useTooltip
98
* @output Exports CheckboxInput component, CheckboxInputProps
109
* @position Core implementation; consumed by index.ts, tested by CheckboxInput.test.tsx
@@ -519,9 +518,7 @@ export function CheckboxInput({
519518
}
520519
size={size}
521520
isDisabled={isDisabled}>
522-
{isBusy ? (
523-
<Spinner size="sm" shade="inherit" aria-hidden="true" />
524-
) : null}
521+
{isBusy ? <Spinner size="sm" shade="inherit" /> : null}
525522
</CheckboxControl>
526523
</span>
527524
</div>

‎packages/core/src/CommandPalette/CommandPaletteInput.test.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @file CommandPaletteInput.test.tsx
55
* @input Uses vitest, @testing-library/react, CommandPaletteInput, Dialog
6-
* @output Unit tests for CommandPaletteInput and its decorative busy-indicator placement
6+
* @output Unit tests for CommandPaletteInput component
77
* @position Testing; validates CommandPaletteInput.tsx implementation
88
*/
99

@@ -377,10 +377,7 @@ describe('CommandPaletteInput popup context', () => {
377377
</CommandPaletteContext>,
378378
);
379379

380-
const spinner = screen.getByLabelText('Loading', {
381-
selector: '.astryx-spinner',
382-
});
383-
expect(spinner).toHaveAttribute('aria-hidden', 'true');
380+
const spinner = screen.getByRole('status');
384381
const trailingContent = screen.getByTestId('trailing-content');
385382
expect(trailingContent.parentElement?.firstElementChild).toContainElement(
386383
spinner,

‎packages/core/src/CommandPalette/CommandPaletteInput.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
'use client';
44
/**
55
* @file CommandPaletteInput.tsx
6-
* Composes a silent Spinner; the palette owns busy feedback.
76
* @input Uses React, StyleX, Icon, CommandPaletteContext, DialogContext
87
* @output Exports CommandPaletteInput component and props
98
* @position Search input for the command palette
@@ -336,7 +335,7 @@ export function CommandPaletteInput({
336335
<span {...stylex.props(styles.end)}>
337336
{ctx?.isBusy && (
338337
<span {...stylex.props(styles.icon, styles.spinner)}>
339-
<Spinner size="sm" aria-hidden="true" />
338+
<Spinner size="sm" />
340339
</span>
341340
)}
342341
{hasEndContent && endContent}

‎packages/core/src/ComplexSelector/ComplexSelector.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/**
66
* @file ComplexSelector.tsx
7-
* Composes a silent Spinner; the selector owns busy feedback.
87
* @input Uses React, StyleX, Field, Icon slots, Layer positioning, and usePopover
98
* @output Exports a rich-selector shell with exact token-sized input, secondary, and ghost triggers, plus an imperative open/close handle
109
* @position Core implementation; consumed by index.ts
@@ -791,7 +790,7 @@ export function ComplexSelector<Value>({
791790
{...stylex.props(styles.trigger)}>
792791
<span {...stylex.props(styles.triggerText)}>{triggerContent}</span>
793792
</button>
794-
{isBusy && <Spinner size="sm" aria-hidden="true" />}
793+
{isBusy && <Spinner size="sm" />}
795794
<Icon
796795
icon="chevronDown"
797796
size="sm"

‎packages/core/src/DateInput/DateInput.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/**
66
* @file DateInput.tsx
7-
* Composes a silent Spinner; the field owns busy feedback.
87
* @input Uses React, useId, useState, useCallback, useRef, Field, Icon, Calendar, usePopover, InputGroupContext
98
* @output Exports DateInput component, DateInputProps
109
* @position Core implementation; consumed by index.ts, tested by DateInput.test.tsx
@@ -933,7 +932,7 @@ function PointerDateField({
933932
onClick={handleClear}
934933
/>
935934
)}
936-
{isBusy && <Spinner size="sm" aria-hidden="true" />}
935+
{isBusy && <Spinner size="sm" />}
937936
{statusIcon}
938937
{popover.render(
939938
<Calendar

‎packages/core/src/DateInput/NativeDateField.test.tsx‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @file NativeDateField.test.tsx
55
* @input Uses vitest, @testing-library/react, DateInput
6-
* @output Unit tests for the OS-picker surface (`nativePicker`) and its silent busy indicator
6+
* @output Unit tests for the OS-picker surface (`nativePicker`)
77
* @position Testing; validates NativeDateField.tsx
88
*
99
* Every test renders through `DateInput` with a pointer stubbed, so the
@@ -222,9 +222,7 @@ describe('DateInput nativePicker', () => {
222222
expect(changeAction).toHaveBeenCalledExactlyOnceWith('2026-03-21');
223223
expect(getInput()).not.toBeDisabled();
224224
expect(getInput()).toHaveAttribute('aria-busy', 'true');
225-
expect(
226-
screen.getByLabelText('Loading', {selector: '.astryx-spinner'}),
227-
).toBeInTheDocument();
225+
expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();
228226
expect(screen.getByText('March 21, 2026')).toBeInTheDocument();
229227

230228
fireEvent.change(getInput(), {target: {value: '2026-03-22'}});
@@ -599,9 +597,7 @@ describe('DateInput nativePicker', () => {
599597

600598
expect(calls).toEqual(['onChange', 'changeAction']);
601599
expect(changeAction).toHaveBeenCalledExactlyOnceWith(undefined);
602-
expect(
603-
screen.getByLabelText('Loading', {selector: '.astryx-spinner'}),
604-
).toBeInTheDocument();
600+
expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();
605601
await act(async () => resolveAction());
606602
});
607603

‎packages/core/src/DateInput/NativeDateField.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/**
66
* @file NativeDateField.tsx
7-
* Composes a silent Spinner; the field owns busy feedback.
87
* @input Uses React, Field, Icon, InputClearButton, Spinner, useCalendarConstraints, hasEditableDateSegments
98
* @output Exports NativeDateField — the OS-picker touch surface
109
* @position One of DateInput's three surfaces. `DateInput` picks the pointer
@@ -688,7 +687,7 @@ export function NativeDateField({
688687
onClick={handleClear}
689688
/>
690689
)}
691-
{isBusy && <Spinner size="sm" aria-hidden="true" />}
690+
{isBusy && <Spinner size="sm" />}
692691
{statusIcon}
693692
{showsDisabledMessage &&
694693
disabledMessageTooltip.renderTooltip(disabledMessage)}

0 commit comments

Comments
 (0)