Skip to content

fix(search-modal): add ARIA combobox semantics to quick search#1706

Open
caugner wants to merge 1 commit into
mainfrom
1175-search-autocomplete-a11y
Open

fix(search-modal): add ARIA combobox semantics to quick search#1706
caugner wants to merge 1 commit into
mainfrom
1175-search-autocomplete-a11y

Conversation

@caugner

@caugner caugner commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

Add ARIA combobox semantics to the quick-search autocomplete (search-modal):

  • The input gets role="combobox", aria-autocomplete="list", aria-controls, aria-expanded, and aria-activedescendant.
  • The results list becomes a listbox with option children carrying ids and aria-selected.
  • A visually-hidden role="status" live region announces the result count.
  • Arrow-key navigation keeps focus on the input and moves the active option via aria-activedescendant; the active index resets on input so it can't point past a shrunken result set.
  • Adds search-modal-results-status and search-modal-results-label strings, translated for de, fr, ja, zh-CN.

Motivation

The quick-search autocomplete had no combobox semantics, so with a screen reader no announcement was made when results appeared, and arrow-key navigation re-read the typed query instead of the highlighted option. This intends to follow the APG combobox-with-listbox pattern plus GitHub's result-count announcement.

Additional details

  • Tested most of it locally with VoiceOver on macOS.
  • The other locales (es, ko, pt-BR, ru, zh-TW) don't translate search-modal and fall back to en-US, so they were left unchanged.

Related issues and pull requests

Fixes #1175.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

b720866 was deployed to: https://fred-pr1706.review.mdn.allizom.net/

Add the combobox/listbox roles, `aria-activedescendant`, and a
`role="status"` live region to the quick-search autocomplete so that
screen readers announce when results appear and read the highlighted
option's text during arrow-key navigation.

Keyboard navigation keeps focus on the input and moves the active option
via `aria-activedescendant`; the active index is reset on input so it
can't point past a shrunken result set.

Add the `search-modal-results-status` and `search-modal-results-label`
strings, translated for `de`, `fr`, `ja`, and `zh-CN`.
@caugner
caugner force-pushed the 1175-search-autocomplete-a11y branch from fe961da to 77d94d8 Compare July 17, 2026 18:10
@caugner caugner changed the title feat(search-modal): add ARIA combobox semantics to quick search fix(search-modal): add ARIA combobox semantics to quick search Jul 17, 2026
@caugner
caugner marked this pull request as ready for review July 17, 2026 18:11
@caugner
caugner requested a review from a team as a code owner July 17, 2026 18:11
@caugner
caugner requested a review from LeoMcA July 17, 2026 18:11
Comment on lines +294 to +296
aria-activedescendant=${
hasOptions ? `search-modal-result-${this._selected}` : nothing
}

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.

aria-activedescendant can reference a non-existent option during an in-progress re-search. While _queryIndex is PENDING, the complete renderer isn't called so the result <li>s are unmounted, but @lit/task keeps .value set to the previous non-empty results. So hasOptions stays true and aria-activedescendant points at search-modal-result-0, while the only rendered option is the trailing site-search <li> whose id is search-modal-result-${siteSearchIndex} (the stale, non-zero length). Since every keystroke triggers a new task run, this dangling reference occurs on each refinement.

Gate aria-activedescendant on the completed state (e.g. reuse searchComplete) so it only references options that are currently rendered.

AI-generated review by Claude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[a11y] MDN search autocomplete broken for screen reader users

2 participants