Repository navigation
fix(inputs): silence the busy Spinner and announce the busy start once (TextInput, TextArea, Selector, MultiSelector) - #7920
Conversation
…e (TextInput, TextArea, Selector, MultiSelector)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsMultiSelector (@astryxdesign/core) · View in Storybook
TextArea (@astryxdesign/core) · View in Storybook
TextInput (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression46 of 494 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
| requestAnimationFrame(() => { | ||
| region.textContent = message; | ||
| setTimeout(() => { | ||
| if (region.textContent === message) { | ||
| region.textContent = ''; | ||
| } | ||
| }, CLEAR_DELAY_MS); | ||
| }); |
There was a problem hiding this comment.
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.
… in-dialog region's frame and timer
There was a problem hiding this comment.
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]
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,SelectororMultiSelectorbecomes busy, it renders aSpinnerthat mounts as its ownrole="status"region already named "Loading". Many screen readers skip a live region that appears together with its content, and the control already exposesaria-busy, so the Spinner is a second owner of the same feedback.Problem and solution fit
{isBusy && <Spinner size="sm" />}. The Spinner's root isrole="status"with its name, inserted in the same commit.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 aDialogthat opens in the same commit (it callsshowModal()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.loadingcatalog entry, whose description now says so), so the announced and shown words still match.Expected behavior and authority
spec:AST-086(current):family:input-fieldsmembers and other busy controls (TextInput, TextArea, Selector, MultiSelector, …): each composes a Spinner withrole="status"inside the busy control. Under FR8 that Spinner is silent and each control announces its own busy state through the channel."component:SelectorFR5 (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
hooks/useBusyAnnouncement.ts(≈60 lines of code, with the in-modal region).aria-hidden="true"on the existing Spinner.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 andaria-hiddenand 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
defaultstory from Storybook built atmain7370328(before) and atdbf82f419eand again at this heada751043214(after). The script setsisLoading: truethrough the Storybook args channel, records every live region inserted and every text write inside one, and readsAccessibility.getFullAXTree.main)aria-busyon the control; a Spinner<span role=status aria-label="Loading">is inserted already named, and the accessibility tree exposes astatusnamed "Loading"; nothing is written to any live regionaria-busyunchanged; the Spinner isaria-hidden="true"and is not in the accessibility tree;Loadingis written once to the shared polite channelInside an open native modal (the same stories, with the rendered root moved into a
<dialog>opened withshowModal();:modalis true), at heada751043214:main)statusnamed "Loading" is the Spinner itself, inserted already named; no live text writtenLoadingis written into the in-dialog busy region, which the accessibility tree exposes as astatus; nothing goes to the inert body channelThe "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
Testing
pnpm check:repoandcheck:changesetsran in the commit hook.