Repository navigation
fix(core): a search's busy start is never announced after its outcome - #8235
Conversation
… (AST-086 FR8) useBusyAnnouncement returns a settle function that drops a busy start still waiting for its frame. BaseTypeahead and CommandPalette call it when a typed query's search settles, whose outcome (a count, or the rendered empty state) is announced next, so a fast search's 'Loading' can no longer follow or replace it.
…-internal context The input's settle registration moves off the exported CommandPaletteContext value onto a context this package does not export, and owner-level tests cover a search that settles before its busy start is announced.
…s message changes; name BaseTypeahead in the changeset
…k passes; trim the changeset to what changes
|
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 PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression46 of 498 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.
This looks good to me: dropping a typed query's pending “Loading” once its search settles matches spec:AST-086 FR8, and the new owner-level cases reproduce the stale announcement before the fix and pass after it. No changes are needed. As a follow-up outside this pull request, the modal CommandPalette still sends its result count to the page-level live region that the open dialog hides, so a fast query there is now silent until counts are delivered inside the modal.
[Automated review]
… identical repeat once (#8244) ## 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 - **Why does it happen?** `useAnnounce` clears 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. - **Why does it hurt?** An earlier status is silently dropped, and the user never learns it. - **Why does it matter?** `spec:AST-086` FR9 (current since #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-086` FR9 governs joining, the identical repeat and the clear. - FR8 (with #8235) says a pending busy start is dropped once its outcome has announced. This covers the last case FR9 makes possible: a busy start already written to the channel when its outcome arrives. ## Smallest restoration - **Joining:** `useAnnounce` keeps 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. - **Withdrawing a busy start:** `useBusyAnnouncement`'s settle function (from #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. - **Tests:** lab `ListInput` tests 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 - **Before:** on `main`, these `useAnnounce` tests fail: - "joins polite/assertive messages announced in the same frame, in order"; - "starts a new announcement for a message after the joined one is exposed"; - "keeps an identical message repeated in the same frame once". The busy-start test "withdraws a busy start written to the channel but not yet exposed" also fails without the withdrawal. - **After:** all pass. Existing announcement tests (result counts, empty states, busy starts) pass across Selector, MultiSelector, Typeahead, CommandPalette, Tokenizer and DropdownMenu, with no doubled ("1 result 1 result") or stale ("2 results Loading") text. - **Mutation-sensitive proof:** - Removing the identical-repeat check fails its test. - Removing the clear of queued messages fails "clears messages joined but not yet exposed". - Removing the withdrawal fails its test. - Removing the per-announcer count fails "withdraws only its own busy start when another owner wrote the same words". ## Scope - [x] One defect is restored. - [x] Separable contradictory or unsettled tagalongs were removed or split. - [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label. - [x] Public text and artifacts contain no internal Meta context. 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. - All announcement tests pass. - The CommandPalette perf benchmark and two DropdownMenu jsdom audit runs timed out while the machine was heavily loaded. They pass when re-run alone, on both this branch and `main`. - Core typecheck and eslint on the touched files are clean, and `pnpm check:repo` passes. - Evidence is DOM-level (`spec:AST-009` FR4, FR19): which region carries the text, the text itself and how many updates, with no screen-reader claim.
Replaces #8137, which was closed at its review-round limit. This version carries that PR's last revision plus a typing fix to one test. A maintainer approved the retry.
User impact
A screen-reader user who types into a BaseTypeahead or CommandPalette can hear "Loading" after the results are already in: either right after the result count, or replacing it. This happens when a search finishes within about a frame of starting. The busy start's announcement waits a frame, and when the search beats it, the stale "Loading" is still spoken.
After this change, a busy start that has not been announced yet is dropped once the same search's outcome is about to be announced.
Problem and solution fit
useBusyAnnouncementannounces a busy start one frame after the owner becomes busy, and only React's commit of the settled state cancels that frame. When the search resolves before that commit, the owner announces the outcome first and the busy start's frame fires afterwards.spec:AST-086FR8 (current since spec(AST-086): identical same-frame repeats are one message; no busy start after its outcome #8102) says a pending busy start is dropped once the same operation's outcome has announced.Expected behavior and authority
spec:AST-086FR8: each busy start is announced once, and a pending busy start is dropped once the same operation's outcome has announced.Smallest restoration
useBusyAnnouncement: returns a settle function. It cancels a busy start still waiting for its frame and does not reschedule it while the owner is still busy. Callers that ignore the return value are unchanged.CommandPaletteInput, so the input registers its settle function with the palette through a new context,busyStartSettle.ts. The package does not export that context, so the exportedCommandPaletteContextValueis unchanged. The opening (bootstrap) load announces no outcome, so it does not settle, and its busy start behaves as before.There is no public API change.
useBusyAnnouncementand the new context are internal and are not exported.Evidence
main,useBusyAnnouncement.test.tsx"drops a busy start its owner settled before it was announced" fails, because the hook returns nothing to call.BusyOwnerAnnouncement.test.tsxadds cases for BaseTypeahead, Typeahead and an inline CommandPalette. Each search settles in a frame callback that runs before the busy start's frame. Each frame callback runs in its own task, as browsers run microtasks between frame callbacks, which jsdom does not. The outcome is announced, and "Loading" never is. These cases fail when the settle call is removed, and fail for BaseTypeahead when the settle call is moved to before the search starts.BusyOwnerAnnouncementsuite passes.cancelAnimationFramefails two hook tests.Scope
The FR9 conformance change (joining same-frame messages in the shared channel, keeping an identical repeat once, and withdrawing a busy start its outcome overtook in the channel) follows in a separate PR. It builds on this one.
Testing
pnpm exec vitest run packages/core/src/hooks packages/core/src/__tests__/BusyOwnerAnnouncement.test.tsx packages/core/src/Typeahead packages/core/src/CommandPalette: 875 passed (the CommandPalette perf benchmark times out only when the machine is overloaded, and passes alone).tsc --noEmitfor core and eslint on the touched files are clean.spec:AST-009FR4, FR19): announcement routing and counts, with no screen-reader claim.