Skip to content

fix(inputs): silence the busy Spinner and announce the busy start once (TextInput, TextArea, Selector, MultiSelector) - #7920

Merged
cixzhang merged 4 commits into
mainfrom
fix/busy-inputs-silence-spinner-1
Oct 22, 2026
Merged

cixzhang merged 4 commits into
mainfrom
fix/busy-inputs-silence-spinner-1

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Screen-reader users don't reliably hear that a field or selector has started loading, and sometimes hear it from two owners at once. When TextInput, TextArea, Selector or MultiSelector becomes busy, it renders a Spinner that mounts as its own role="status" region already named "Loading". Many screen readers skip a live region that appears together with its content, and the control already exposes aria-busy, so the Spinner is a second owner of the same feedback.

Problem and solution fit

  • Why it occurs. Each control renders {isBusy && <Spinner size="sm" />}. The Spinner's root is role="status" with its name, inserted in the same commit.
  • Why it harms the task. The busy start is often not spoken at all, and when it is, two elements claim it.
  • Fix. The composed Spinner is aria-hidden (decorative, as Button and ChatToolCalls already do), and each control announces its busy start once through the shared polite channel. A small internal hook, useBusyAnnouncement(isBusy, message, elementRef) (not exported), holds the once-per-busy-start guard: a rerender or a StrictMode replay does not repeat it, and settling re-arms it. The route is chosen one frame after the busy start, so a Dialog that opens in the same commit (it calls showModal() in its own Effect, which runs after the field's) is already modal. While the control sits inside an open native modal, where the body-level channel is not exposed, the hook announces through one persistent polite region inside that dialog instead. The region is inserted empty, filled on the next frame, cleared after the same delay as the channel, and reused for later busy starts. Each write cancels that region's earlier pending write and clear. This matches how Switch already announces its busy state. The words are the same "Loading" the Spinner exposed (the existing @astryx.spinner.loading catalog entry, whose description now says so), so the announced and shown words still match.

Expected behavior and authority

spec:AST-086 (current):

  • FR8: "A visual indicator composed inside a component that owns the task, such as a Spinner in a busy control, announces nothing and carries no live role. The owning component announces its busy state once per busy start (FR6), through the channel or through a persistent region that FR3 allows."
  • FR6: once per occasion; rerender and StrictMode replay do not repeat it.
  • Platform support: "Until then, a busy owner rendered inside a native modal announces its busy state through a persistent region inside that modal (FR3, FR8)."
  • Current-state impact: "family:input-fields members and other busy controls (TextInput, TextArea, Selector, MultiSelector, …): each composes a Spinner with role="status" inside the busy control. Under FR8 that Spinner is silent and each control announces its own busy state through the channel."

component:Selector FR5 (the listbox suppresses empty and no-results output while loading) is unchanged. The existing Selector/MultiSelector loading tests still assert that no empty or no-results message is spoken; the only words the channel may now hold are the busy start.

Part of #7856. This PR covers the first four owners. The rest follow in separate PRs within size limits, and Switch is already done.

Smallest restoration

  • New internal hooks/useBusyAnnouncement.ts (≈60 lines of code, with the in-modal region).
  • In each of the four controls: one hook call (passing an existing container or trigger ref) and aria-hidden="true" on the existing Spinner.
  • A description update for one catalog key in locales/en.json, and a patch changeset. No public prop, markup structure, style or visual change.

Evidence

  • Reproduction on main: the new __tests__/BusyOwnerAnnouncement.test.tsx (16 cases across the four controls: silent Spinner; one announcement under StrictMode; none while idle; again on each new busy start; inside an already-open modal, a region in the dialog is inserted empty and then says "Loading" while the body channel stays silent; a field already busy when its dialog opens in its own Effect also announces inside the dialog; 20 cases) fails with only the four component files reverted. The "busy as its dialog opens" cases also fail against the previous head, which chose the route in the Effect. On this branch, the TextInput, TextArea, Selector, MultiSelector and Dialog suites plus the new file all pass (833).

  • Existing tests that found the busy Spinner by role="status" now assert it is present and aria-hidden and that no accessible "Loading" status exists. The three "nothing spoken while loading" assertions now allow only the busy start (or the channel already cleared).

  • Real-browser accessibility tree: headless Chrome 156 runs each control's default story from Storybook built at main 7370328 (before) and at dbf82f419e and again at this head a751043214 (after). The script sets isLoading: true through the Storybook args channel, records every live region inserted and every text write inside one, and reads Accessibility.getFullAXTree.

    control before (main) after (this head)
    TextInput, TextArea, Selector, MultiSelector (all four identical) aria-busy on the control; a Spinner <span role=status aria-label="Loading"> is inserted already named, and the accessibility tree exposes a status named "Loading"; nothing is written to any live region aria-busy unchanged; the Spinner is aria-hidden="true" and is not in the accessibility tree; Loading is written once to the shared polite channel

    Inside an open native modal (the same stories, with the rendered root moved into a <dialog> opened with showModal(); :modal is true), at head a751043214:

    control before (main) after (this head)
    all four the exposed status named "Loading" is the Spinner itself, inserted already named; no live text written the Spinner is hidden; Loading is written into the in-dialog busy region, which the accessibility tree exposes as a status; nothing goes to the inert body channel

    The "busy as its dialog opens" ordering could not be reproduced through Storybook's args channel (a dialog opened from outside React opens before the field's Effect either way), so it is proven by the jsdom red-arm above.

    Spoken output is not claimed. Under spec:AST-009 (FR4, FR19), DOM and accessibility-tree routing is the evidence for an announcement claim.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm vitest run --project ui packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx packages/core/src/TextInput packages/core/src/TextArea packages/core/src/Selector packages/core/src/MultiSelector

pnpm check:repo and check:changesets ran in the commit hook.

…e (TextInput, TextArea, Selector, MultiSelector)
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 22, 2026 4:11pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 22, 2026
@astracat-bot

astracat-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 22, 2026, 4:40 PM UTC

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

MultiSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 2626 -
Complexity N/A Very High (338) -
TextArea (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 454 -
Complexity N/A Very High (68) -
TextInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 364 -
Complexity N/A Very High (62) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

46 of 494 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

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.

Changes requested. Silencing the busy Spinner and announcing the busy start once through the shared channel matches spec:AST-086 FR8 and FR6 for fields in the page, but inside an open native modal such as a Dialog the announcement only reaches the body-level channel, which is not exposed while the modal is open, and with the Spinner now hidden these fields announce nothing there. AST-086's Platform support asks a busy owner inside a native modal to announce through a persistent region inside that modal. Please route the busy start through such a region when the control is inside an open modal, and add a test with a busy field inside an open Dialog.

[Automated review]

return;
}
hasAnnouncedRef.current = true;
announce(message, 'polite');

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.

Inside an open native modal (Dialog, Drawer with scrim, BottomSheet) this body-level channel is not exposed to assistive technology, and with the Spinner now aria-hidden nothing inside the modal carries the busy start. spec:AST-086 Platform support: "a busy owner rendered inside a native modal announces its busy state through a persistent region inside that modal (FR3, FR8)." Consider writing to a persistent, initially empty polite region inside the open modal when the control is in one, and adding a test with a busy field inside an open Dialog.

@astracat-bot astracat-bot Bot left a comment

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.

Changes requested. Hiding the busy Spinner and announcing "Loading" once per busy start matches spec:AST-086 FR8 and FR6, and the new in-dialog region works when a field becomes busy after its Dialog is already open. A field that is busy as its Dialog opens, such as a Selector whose options start loading on open, still announces through the page-level channel, because the hook picks the route in its Effect before the dialog's own Effect calls showModal(), so nothing inside the modal exposes "Loading" (AST-086 Platform support). Please pick the route once the host has opened, add a test that opens a Dialog with an already-busy field, and give the in-dialog region's frame and clear timer an owner that cancels them on the next write.

[Automated review]

return;
}
hasAnnouncedRef.current = true;
const dialog = openModalDialogOf(elementRef.current);

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.

This reads dialog.open in the field's own Effect. Dialog and BottomSheet call showModal() from their own passive Effect, which React runs after this one, so a field that is busy in the commit that opens its dialog takes the body-level branch, and its text lands in a channel the open modal makes inert. In Chromium, opening a Dialog whose Selector starts loading on open leaves nothing in the dialog exposing "Loading". spec:AST-086 Platform support asks for the in-modal region in that state. Consider deciding the route once the host has opened (for Dialog and BottomSheet the next frame is already after showModal()), not announcing on the page for a field inside a closed <dialog>, and adding a test that opens a Dialog with an already-busy field.

Comment on lines +87 to +94
requestAnimationFrame(() => {
region.textContent = message;
setTimeout(() => {
if (region.textContent === message) {
region.textContent = '';
}
}, CLEAR_DELAY_MS);
});

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.

Nothing keeps or cancels this frame or the clear timer it starts, so a second busy start in the same dialog within 2 seconds is cleared early by the first timer (both texts are "Loading"), and a field removed within a frame still writes into the region. architecture:react-component-runtime INV3 and INV5 want one owner for them. Keeping the region's pending frame and timer with the region and cancelling them on each write, as useAnnounce does for the channel, keeps StrictMode working; cancelling in the Effect cleanup alone would drop the announcement behind the ref guard.

@astracat-bot astracat-bot Bot left a comment

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.

This looks ready to merge. Hiding the busy Spinner and announcing "Loading" once per busy start matches spec:AST-086 FR8 and FR6 in the page, and the busy start now reaches the region inside a Dialog both after it opens and when it opens in the same update, which resolves the earlier in-modal gap. One case is left open: a field that is already busy before its Dialog opens announces on the page and says nothing more once the dialog opens; AST-086 does not define that case today, so it may deserve a follow-up on the record.

[Automated review]

@cixzhang
cixzhang merged commit 2b60fa6 into main Oct 22, 2026
69 checks passed
@cixzhang
cixzhang deleted the fix/busy-inputs-silence-spinner-1 branch October 22, 2026 16:44

This branch was successfully deployed

1 active deployment
Preview — a7510432 Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant