Repository navigation
fix(useAnnounce): messages announced in the same frame are joined, an identical repeat once - #8244
Conversation
…FR9) WIP, held: joining exposes producer duplicates and a stale busy announcement in Selector, MultiSelector, CommandPalette and Typeahead tests.
…spoken once (AST-086 FR9)
…in the channel (AST-086 FR8) Once FR9 joins same-frame messages, a busy start written to the channel can still be waiting when its outcome announces. Settling now withdraws it, so a screen reader hears the outcome alone rather than 'Loading 1 result'.
…ne change Keystrokes typed in one frame are joined into one announcement (spec:AST-086 FR9), so tests asserting what one query announces paste it instead of typing it key by key.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
|
There was a problem hiding this comment.
Joining same-frame messages in useAnnounce matches spec:AST-086 FR9 and the new hook tests prove it, but two things need fixing before this can merge.
useBusyAnnouncement's settle withdraws the first queued message with the same words, so when a Typeahead's search resolves in the frame where another busy control has just written "Loading" (every default busy label in English), that control's busy start is never announced (FR8, FR9); please withdraw only the settling owner's own pending write and add a two-owner test.- CI
test-ui (3/4)fails on two tests inpackages/lab/src/ListInput/ListInput.test.tsx(lines 584 and 1281) that pass onmain: they assert exact live-region text that FR9 now joins, including text queued by earlier tests in the same file.
[Automated review]
| } | ||
| // Written to the channel but not yet exposed: withdraw it too. | ||
| if (channelMessageRef.current != null) { | ||
| withdrawPendingAnnouncement(channelMessageRef.current, 'polite'); |
There was a problem hiding this comment.
This removes the first queued entry with these words, whoever wrote it. Identical same-frame messages share one entry, and channelMessageRef keeps the words after they were exposed, so a settle here can withdraw another busy control's pending "Loading" (every default busy label is "Loading" in English), and that control's busy start is never announced (spec:AST-086 FR8, FR9). Withdrawing only this owner's own still-pending write, for example through a handle from an internal enqueue plus a writer count on a deduplicated entry, and a two-owner test would close it.
…y start; ListInput tests read FR9's joined text Each pending channel message counts the announcers waiting on it, so one owner settling leaves another owner's identical 'Loading' in place. ListInput's tests clear the shared region between tests and expect a same-frame grab and return to be spoken together.
There was a problem hiding this comment.
Joining same-frame messages in useAnnounce and withdrawing only a busy control's own pending start now match spec:AST-086 FR9 and FR8, and the new hook tests prove both, including the two-owner case. The earlier withdrawal and ListInput test problems are fixed, so this is ready from a spec and correctness standpoint. The one red check, pr-a11y, fails because the workflow on main now runs packages/lab/src/__tests__/ReorderGripPinchZoom.a11y.chromium.spec.ts, which this branch predates; updating the branch from main should clear it.
[Automated review]
…e the query Main now joins the messages announced within one frame into one (useAnnounce, meta#8244). In jsdom a typed query's keystrokes all land in one frame, so the region held 'New label “Urge” New label “Urgen” New label “Urgent”' and the two cases that read it failed. They now paste the query: one change, one announcement, as a person's separate keystrokes are separate frames in a browser. The Chromium spec, where each keystroke is its own frame, still sees one announcement per query. Tests only.
…e the query Main now joins the messages announced within one frame into one (useAnnounce, meta#8244). In jsdom a typed query's keystrokes all land in one frame, so the region held 'New label “Urge” New label “Urgen” New label “Urgent”' and the two cases that read it failed. They now paste the query: one change, one announcement, as a person's separate keystrokes are separate frames in a browser. The Chromium spec, where each keystroke is its own frame, still sees one announcement per query. Tests only.
…e the query Main now joins the messages announced within one frame into one (useAnnounce, meta#8244). In jsdom a typed query's keystrokes all land in one frame, so the region held 'New label “Urge” New label “Urgen” New label “Urgent”' and the two cases that read it failed. They now paste the query: one change, one announcement, as a person's separate keystrokes are separate frames in a browser. The Chromium spec, where each keystroke is its own frame, still sees one announcement per query. Tests only.
…e the query Main now joins the messages announced within one frame into one (useAnnounce, meta#8244). In jsdom a typed query's keystrokes all land in one frame, so the region held 'New label “Urge” New label “Urgen” New label “Urgent”' and the two cases that read it failed. They now paste the query: one change, one announcement, as a person's separate keystrokes are separate frames in a browser. The Chromium spec, where each keystroke is its own frame, still sees one announcement per query. Tests only.
…thdrawn, not joined (#8640) ## Why When input outpaces a frame (a barcode scanner, dictation, automation), a screen-reader user hears MultiSelector's stale statuses joined together: `1 result Create "Urg" Create "Urge" Create "Urgen" Create "Urgent"`. ## What led to it Found while checking the text-entry components' accessibility tests (part of bringing Astryx's touch behavior to parity with iOS's UIKit, text entry first). #8244 made the announcer join every message written before the previous one is read out (`spec:AST-086` FR9), so two components speaking in the same frame are both heard. MultiSelector states its search's status on every keystroke, so fast typing joins statuses that no longer apply. Its CreateRow accessibility spec failed on that, and now accepts the joined text. ## The record #9070, approved by the spec owner, amends `spec:AST-086` FR9, FR13 and FR14: a `useAnnounce` instance created with `hasReplace` withdraws its own previous message while it is not yet exposed, whatever their urgencies, and the newer is spoken in the region of its own urgency; messages from other instances still join. This pull request implements it and lands after #9070, so its public option is settled by that record, not decided here (`spec:AST-002` FR19). ## Options and tradeoffs - Debounce MultiSelector's status: delays every announcement, and every component would repeat it. - Keep the joined text: scanner and dictation users keep hearing stale counts. - Replace per announcer instance, in the shared announcer: fixes it once for every caller, and different instances still join. ## Why this choice It is the shape #9070 records. `useAnnounce({hasReplace: true})` is one optional field; the `announce(message, politeness)` it returns is unchanged. Each write gives its announcer a receipt kept beside the words, wherever the route put them: the shared region, a modal's container, words held for an exiting modal, or a message waiting for its modal to be presented. When a modal hands its waiting words on (it leaves the accessibility tree, exits, closes, a step is left, or its write frame finds it unexposed), they move one delivery per announcer and each receipt follows its words. A receipt takes back only its own share and only while the words wait, so it never reaches equal words another announcer wrote after its own were spoken. The busy-announcement hook takes its start back through the same receipt. MultiSelector sends its result count, its create row and its empty-panel message through one such instance; selection changes keep their own. Selector, Typeahead and the others adopt it separately. ## How to check it 1. Run `MultiSelector/CreateRow.a11y.chromium.spec.ts` in Chromium. It types into the create row at about four keystrokes per frame. It now reads the two search statuses exactly, in place of the `newestMessage` regex; the creation message, which comes from another announcer and can still join, keeps the regex. Expected: on main it fails on the joined statuses; with this change the polite region reads `1 result`, then `Create "Urgent"`. 2. With a screen reader, type into MultiSelector at a normal pace. Expected: each status is read as before. ## Evidence - CreateRow spec, tightened as above: on main 560c666 it failed 6 of 10 runs alone and 35 of 48 at 8 workers, reading `Create "Urge" Create "Urgen" Create "Urgent"`; with this change it passes 10 of 10 alone and 48 of 48 at 8 workers. - Unit tests that fail on main first: four statuses in one frame say the last; a count then an empty panel, and an empty panel then a count, say the newer; the same inside a Dialog's container; a `hasReplace` instance's messages in one frame, polite then assertive, inside a modal and in the commit that presents one; and its first message, handed on by its modal before it was exposed (the Dialog leaving the accessibility tree and coming back, a sheet's exit and close, the Dialog closing, a step left for the next one, or its write frame finding it unexposed), is taken back by its next. Guards that pass on main and with the change: other instances and plain instances still join, a shared share stays, an exposed message stays, a selection change and a count in one frame are both said, and inside a modal an equal message another announcer writes after the count's was spoken, and another announcer's share of words held while a sheet exits, both stay. - Local gates at 4e89f16 (one commit on main bb18c81): build, typecheck, repo checks and Prettier pass; the core UI suite passes (16,616 tests); the node suite passes except the two `cache.test.mjs` lock tests that fail on this machine without the change too (#8520).
User impact
When two status messages are announced in the same frame, a screen-reader user hears only the last one. For example, a search's result count and a confirmation announced together lose the count. The shared announcer (
useAnnounce) gives each message its own frame, and each frame overwrites the previous text.After this change, messages announced in the same frame are spoken together, in order, and an identical repeat is spoken once. An empty message still clears the region, including messages joined but not yet spoken.
Problem and solution fit
useAnnounceclears the region and schedules one animation frame per message. Two messages in one frame write first one, then the other, so the region exposes only the second.spec:AST-086FR9 (current since spec(AST-086): identical same-frame repeats are one message; no busy start after its outcome #8102) says messages written before the previous one is exposed are joined in order, none is dropped, an identical repeat within one frame is one message, and an empty message clears joined-but-unexposed text.Expected behavior and authority
spec:AST-086FR9 governs joining, the identical repeat and the clear.Smallest restoration
useAnnouncekeeps one pending frame per region and one queue of messages. The frame exposes the queue joined with spaces. An identical message already queued is not queued again, and an empty message clears the queue with the region.useBusyAnnouncement's settle function (from fix(core): a search's busy start is never announced after its outcome #8235) also withdraws a busy start it already wrote to the channel but that has not been exposed. Each pending message counts the announcers waiting on it, so one owner withdrawing leaves another owner's identical "Loading" in place. The helpers are module-private; nothing new is exported from the hooks index.ListInputtests clear the shared region between tests with an empty announcement, because one test stubs animation frames. A same-frame grab and return is now expected as one joined announcement. The Selector and MultiSelector tests that assert what one search query announces now paste the query as one change. Typing it key by key can land several keystrokes in one frame, and FR9 joins their counts.There is no public API change.
Evidence
main, theseuseAnnouncetests fail:The busy-start test "withdraws a busy start written to the channel but not yet exposed" also fails without the withdrawal.
Scope
Modal routing (FR14) is out of scope and untouched.
Testing
pnpm exec vitest run packages/core/src/hooks packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx packages/core/src/Typeahead packages/core/src/CommandPalette packages/core/src/Selector packages/core/src/MultiSelector packages/core/src/Tokenizer packages/core/src/DropdownMenu: 1764 tests.main.pnpm check:repopasses.spec:AST-009FR4, FR19): which region carries the text, the text itself and how many updates, with no screen-reader claim.