Skip to content

fix(site/src): announce empty command results to screen readers - #32667

Merged
chrifro merged 1 commit into
mainfrom
a11y/status-msg-not-auto-announced
Nov 24, 2026
Merged

chrifro merged 1 commit into
mainfrom
a11y/status-msg-not-auto-announced

Conversation

@bartekgatzcoder

Copy link
Copy Markdown
Collaborator

Screen readers did not announce the "No ... found" messages in cmdk pickers (WCAG 4.1.3 Status Messages). cmdk mounts Command.Empty only when the list has no results, with role="presentation" inside the listbox, so there was no live region to announce it.

Command now renders an sr-only role="status" span next to the listbox. It is mounted before any message appears, and it sits outside the listbox because a status is not an allowed child there. CommandEmpty copies its visible text into that span while cmdk shows it, keeps the copy in sync with a MutationObserver, and clears it on unmount. Only text is copied, so a link inside an empty message (for example in WorkspacesButton) never gets a hidden, focusable duplicate. Nothing changes visually.

Closes DEQ-183

Ticket element UI surface Component
DEQ-183 #1 "No filters found" Agents sidebar filter No longer exists: "Filter agents" is now a dropdown menu with no search, and FilterCombobox already announces this through its own live region
DEQ-183 #2 "No organizations found" New chat org selector CompactOrgSelector → CommandEmpty
DEQ-183 #3 "No models found." Model selector ModelSelector → CommandEmpty
DEQ-183 #4 "No workspaces found" Attach workspace menu AgentChatInput → CommandEmpty
DEQ-183 #5 "No users or groups found" Share chat search Autocomplete → CommandEmpty

The fix is in the shared primitive, so every other CommandEmpty and ComboboxEmpty caller (for example SelectFilter, OrganizationAutocomplete, WorkspaceUserAutocomplete) is announced too.

The empty text now appears twice in the DOM (visible copy and sr-only copy), so three story play functions that used getByText on it were changed to wait only, without assertions. The new Vitest test in Command.test.tsx covers the announcement.

No screenshots: the change is not visible.

Decision log and review notes
  • Grouping: all five elements share one root cause, the shared CommandEmpty primitive, so this is one PR (43 non-test lines).
  • Why a pre-mounted region: this follows fix(site/src): announce copy, loading, and error status messages #32143. A live region that mounts together with its text is not announced reliably, so the region lives on the Command root and only its text changes.
  • Why outside the listbox: a status child inside role="listbox" breaks aria-required-children.
  • Why text, not a portal of children: the first version portaled children into the status. Self-review found that this duplicates interactive content (the WorkspacesButton "Create one now." link) as a hidden tab stop. The test now puts a link in the message and asserts that there is still only one link.
  • Why useCallback: components/ is not compiled by the React Compiler. A stable ref identity stops every keystroke from clearing and rewriting the live region.
  • CommandEmpty no longer accepts a ref, so a caller cannot silently replace the mirror. No caller passes one.
  • Verification: the new test fails without the mirror ref ("Expected element to have text content") and passes with it. Full unit and Storybook suites pass. Axe (4.11) on CompactOrgSelector, ModelSelector, Autocomplete, Combobox and ProviderFilter in the empty state finds the status text outside the listbox and no new violations.
  • Pre-existing, not changed here: axe flags aria-dialog-name on the Radix popover and aria-required-children on the empty cmdk listbox, on both base and branch. MultiSelectCombobox has its own local CommandEmpty and is not covered. If a list is already empty when its popover opens, the region and its text mount together and may not be announced; every case in the ticket happens after typing.
  • OrganizationModelsLayout.stories.tsx > Loading is flaky on main too (1 of 5 runs failed on base). It is unrelated.
  • Self-review: frontend-review FE1 to FE10, frontend-deep-review (8 roles) and frontend-accessibility all pass after the fixes above. I dropped no findings.

🤖 Generated by Coder Agents on behalf of @bartekgatzcoder.

cmdk mounts its empty message only when the list has no results, inside
the listbox, so screen readers never announced "No organizations found",
"No models found.", "No workspaces found" or "No users or groups found"
(WCAG 4.1.3). Command now renders an sr-only status outside the listbox
that is mounted before any message, and CommandEmpty copies its visible
text into it while it is shown.

Refs DEQ-183
@linear-code

linear-code Bot commented Nov 24, 2026

Copy link
Copy Markdown

DEQ-183

@bartekgatzcoder
bartekgatzcoder marked this pull request as ready for review November 24, 2026 12:25

@chrifro chrifro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The shared Command primitive now has a pre-mounted sr-only role="status" outside the listbox, and CommandEmpty copies its text into it. This covers all four remaining DEQ-183 surfaces (org, model, workspace, and user/group pickers); element 1 is already handled by FilterCombobox's own status region. Nits: a virtual-cursor user may hear the empty text twice (visible and sr-only copies), and the getAllByRole("link")).toHaveLength(1) count assertion is borderline TS2, but it guards a real a11y property. Follow-up filed: DEQ-651 (MultiSelectCombobox has its own local CommandEmpty and is not covered).

🤖 Generated by Coder Agents on behalf of @chrifro.

@chrifro
chrifro merged commit 917c3e2 into main Nov 24, 2026
56 checks passed
@chrifro
chrifro deleted the a11y/status-msg-not-auto-announced branch November 24, 2026 12:44
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026

This branch had an error being deployed

1 failed deployment
docs-preview — a23a0ae0 Deployed Nov 24, 2026 by chrifro via cleanup #405
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants