Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/spinner-shared-announcement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[fix] A standalone Spinner used to mount `role="status"` already holding its name, so screen readers often said nothing when it appeared. It is now an indeterminate progress indicator (`role="progressbar"` with no `aria-valuenow`, named by its visible string label, its `aria-label` or a translated "Loading") that announces once through the shared polite channel when it appears after page load, reading its rendered text in order with stacked lines kept apart, or its accessible name (AST-020 FR15; AST-086 FR2, FR7, FR11–FR12; WCAG 2.2 4.1.3). BaseTypeahead, Typeahead and Tokenizer keep their search Spinner named and never live while they announce the search themselves, and app code silences a composed Spinner with `aria-hidden`. No app change is needed (AST-017 FR53): a Spinner given a `role` other than `progressbar` stays silent, as before. The lab EmojiPicker and Schedule now hide their loading rings and announce their own busy start once, and the Comments history dialog announces it inside the dialog (AST-086 FR6, FR8, FR14); their loading words stay readable. Every Spinner's indicator changes from `status` to `progressbar`, so a test that queries it by role changes, including the hidden rings inside Button, CheckboxInput, CheckboxList, CheckIndicator, ChatMessageList, ChatToolCalls, CommandPaletteInput, ComplexSelector, DateInput, DateRangeInput, DateTimeInput, DropdownMenu's sub-menus, FileInput, MultiSelector, Selector, Switch, TextArea, TextInput, Thumbnail and TimeInput, and lab's EmojiPicker, Comments and Schedule.

@korkt-kim
10 changes: 6 additions & 4 deletions packages/core/src/CheckboxList/CheckboxList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,9 @@ describe('CheckboxListItem ARIA props', () => {
// The spinner is decorative — it lives inside the checkbox's
// aria-hidden visual box, so query with hidden:true. The accessible
// loading signal is `aria-busy` on the item (asserted above).
expect(screen.getByRole('status', {hidden: true})).toBeInTheDocument();
const spinner = screen.getByRole('progressbar', {hidden: true});
expect(spinner).toBeInTheDocument();
expect(spinner.closest('[aria-hidden="true"]')).not.toBeNull();
});

it('does not toggle when item-level isLoading is set', () => {
Expand Down Expand Up @@ -948,12 +950,12 @@ describe('CheckboxListItem ARIA props', () => {
// The toggled item becomes busy and shows a spinner; the sibling stays idle.
// The spinner is decorative (inside the aria-hidden box), so query hidden.
expect(
await within(itemA).findByRole('status', {hidden: true}),
await within(itemA).findByRole('progressbar', {hidden: true}),
).toBeInTheDocument();
expect(itemA).toHaveAttribute('aria-busy', 'true');
expect(itemB).not.toHaveAttribute('aria-busy');
expect(
within(itemB).queryByRole('status', {hidden: true}),
within(itemB).queryByRole('progressbar', {hidden: true}),
).not.toBeInTheDocument();
expect(changeAction).toHaveBeenCalledWith(['a']);
});
Expand Down Expand Up @@ -1022,7 +1024,7 @@ describe('CheckboxListItem ARIA props', () => {
await waitFor(() => expect(itemB).toHaveAttribute('aria-busy', 'true'));
expect(itemA).toHaveAttribute('aria-busy', 'true');
expect(
within(itemA).getByRole('status', {hidden: true}),
within(itemA).getByRole('progressbar', {hidden: true}),
).toBeInTheDocument();

// Re-toggling the still-pending item stays blocked.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ async function bindSubject(
name: facts.initialMessage,
});
} else {
await expect(candidates).toContainText([facts.initialMessage]);
const texts = await candidates.evaluateAll(elements =>
elements.map(element =>
(element.textContent ?? '').replace(/\s+/g, ' ').trim(),
Expand Down Expand Up @@ -139,6 +140,22 @@ async function transition(page: Page, name: string): Promise<void> {
);
}

async function expectSpinnerIndicator(
page: Page,
cdp: CDPSession,
name: string,
): Promise<void> {
const harness = createChromiumHarness({
page,
cdp,
subject: page.getByRole('progressbar', {name}),
});
expect(await (await harness.subject()).computed()).toMatchObject({
role: 'progressbar',
name,
});
}

async function runState(
page: Page,
cdp: CDPSession,
Expand All @@ -152,6 +169,12 @@ async function runState(
knownFailures: CORE_STATUS_MESSAGE_KNOWN_FAILURES,
mount: async () => {
await mountState(page, state);
if (
state.binding === 'Spinner announcement channel' &&
state.facts.kind === 'live-region'
) {
await expectSpinnerIndicator(page, cdp, state.facts.initialMessage);
}
return createChromiumHarness({
page,
cdp,
Expand Down Expand Up @@ -180,6 +203,12 @@ for (const state of CORE_STATUS_MESSAGE_BINDING_STATES) {
test.setTimeout(2 * 60 * 1000);
const cdp = await page.context().newCDPSession(page);
const result = await runState(page, cdp, state);
if (
state.binding === 'Spinner announcement channel' &&
state.facts.kind === 'live-region'
) {
await expectSpinnerIndicator(page, cdp, state.facts.replacement);
}
recorded.set(state.id, result);
const report = summarize(STATUS_MESSAGE_PATTERN, [result]);
// eslint-disable-next-line no-console -- the report is this run's artifact
Expand All @@ -190,7 +219,7 @@ for (const state of CORE_STATUS_MESSAGE_BINDING_STATES) {
});
}

test('every expectation is exercised by at least one Core binding state', async ({
test('every Core-applicable expectation is exercised by a binding state', async ({
page,
}) => {
test.setTimeout(4 * 60 * 1000);
Expand All @@ -199,7 +228,9 @@ test('every expectation is exercised by at least one Core binding state', async
for (const state of CORE_STATUS_MESSAGE_BINDING_STATES) {
results.push(recorded.get(state.id) ?? (await runState(page, cdp, state)));
}
expect(neverExercised(results)).toEqual([]);
expect(neverExercised(results)).toEqual([
'status-message.message.name-exposed',
]);
Comment on lines +231 to +233

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both Spinner states now bind the shared channel, so nothing in Chromium checks the indicator's own role and name any more. The component:Spinner verification row AR1, AR2 relies on this suite to fail on "a changed role or name". Once OQ1 settles the role, keep an accessibility-tree assertion of the indicator's role and name next to the channel binding.

expect(
unmatchedKnownFailures(CORE_STATUS_MESSAGE_KNOWN_FAILURES, results),
).toEqual([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type CoreStatusMessageBinding =
| 'Toast announcement channel'
| 'Toast card'
| 'FieldStatus announcement channel'
| 'Spinner'
| 'Spinner announcement channel'
| 'ProgressBar';

export interface CoreStatusMessageBindingDefinition {
Expand Down Expand Up @@ -157,14 +157,13 @@ export const CORE_STATUS_MESSAGE_BINDING_STATES = [
},
{
id: 'spinner-default-label-mounted',
binding: 'Spinner',
binding: 'Spinner announcement channel',
summary:
'a loading spinner is mounted with its default accessible status name',
'a mounted spinner sends its default label and updates through the persistent polite channel',
facts: liveFacts({
role: 'status',
politeness: 'polite',
initialMessage: 'Loading',
messageSource: 'accessible-name',
message: 'Loading',
replacement: 'Saving',
semanticTransitions: ['replace'],
Expand All @@ -173,14 +172,13 @@ export const CORE_STATUS_MESSAGE_BINDING_STATES = [
},
{
id: 'spinner-visible-label-mounted',
binding: 'Spinner',
binding: 'Spinner announcement channel',
summary:
'a loading spinner is mounted with a visible label that names its status role',
'a mounted spinner sends its visible label and updates through the persistent polite channel',
facts: liveFacts({
role: 'status',
politeness: 'polite',
initialMessage: 'Fetching data',
messageSource: 'accessible-name',
message: 'Fetching data',
replacement: 'Saving data',
semanticTransitions: ['replace'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async function renderState(
await waitFor(() =>
expect(document.querySelector('[data-a11y-ready="true"]')).not.toBeNull(),
);
await waitFor(() => expect(subjectFor(state)).toBeInTheDocument());
}

function subjectFor(state: CoreStatusMessageBindingState): Element {
Expand Down Expand Up @@ -130,7 +131,7 @@ describe('Core status-message binding inventory', () => {
).toEqual([
'FieldStatus announcement channel',
'ProgressBar',
'Spinner',
'Spinner announcement channel',
'Toast announcement channel',
'Toast card',
]);
Expand Down
Loading