Skip to content

Accessibility of AJAX search: aria-live, focus restoration, loader semantics#169

Open
loevgaard wants to merge 1 commit into
issue-123-accessible-paginationfrom
issue-133-ajax-accessibility
Open

Accessibility of AJAX search: aria-live, focus restoration, loader semantics#169
loevgaard wants to merge 1 commit into
issue-123-accessible-paginationfrom
issue-133-ajax-accessibility

Conversation

@loevgaard

Copy link
Copy Markdown
Member

What

After every AJAX filter/sort/page change the whole #search-form node is swapped, which was a triple problem for assistive-technology users:

  1. No announcements — the result count was a bare text node. It's now wrapped in a role="status" aria-live="polite" region, so "N results" is announced after each update.
  2. Focus was destroyedreplaceWith() removes the element the user just operated, resetting focus to <body>. search.js #replaceContent() now records the active element's id/name before the swap and restores focus to the equivalent element afterwards (fallback: focus the results region with tabindex="-1"), so keyboard users don't have to tab from the top after every interaction.
  3. The loader had no semantics — the overlay now has role="status" and a translated aria-label ("Loading results…", added to all 12 locales).

Testing

  • e2e announces the result count and restores focus after an AJAX swap: asserts the aria-live hits-count region and that document.activeElement is the equivalent field (f[brand][]) after the swap.
  • Twig/YAML lint pass; the partial-render test still passes.

Closes #133


Stacked on #168 (#123).

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (issue-123-accessible-pagination@f33f2e3). Learn more about missing BASE report.

Additional details and impacted files
@@                        Coverage Diff                         @@
##             issue-123-accessible-pagination     #169   +/-   ##
==================================================================
  Coverage                                   ?   49.21%           
  Complexity                                 ?      797           
==================================================================
  Files                                      ?      140           
  Lines                                      ?     2544           
  Branches                                   ?        0           
==================================================================
  Hits                                       ?     1252           
  Misses                                     ?     1292           
  Partials                                   ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loevgaard loevgaard force-pushed the issue-133-ajax-accessibility branch from 60186b3 to 345085c Compare July 10, 2026 17:16
@loevgaard loevgaard force-pushed the issue-123-accessible-pagination branch 2 times, most recently from 3f9ed37 to 5b2f77a Compare July 10, 2026 17:20
@loevgaard loevgaard force-pushed the issue-133-ajax-accessibility branch from 345085c to 2fc32d3 Compare July 10, 2026 17:20
After every AJAX filter/sort/page change the whole #search-form node is
swapped, which was a triple problem for assistive-technology users.

- Wrap the hits count in a role=status aria-live=polite region so the
  updated "N results" is announced after each update.
- Give the loader overlay role=status and a translated aria-label
  ("Loading results…", added to all 12 locales) so "loading" is conveyed.
- In search.js #replaceContent(): record the active element's id/name
  before the swap and restore focus to the equivalent element afterwards,
  falling back to focusing the results region (tabindex=-1) so focus is
  never dumped back on <body>.

Closes #133
@loevgaard loevgaard force-pushed the issue-123-accessible-pagination branch from 5b2f77a to f33f2e3 Compare July 10, 2026 18:11
@loevgaard loevgaard force-pushed the issue-133-ajax-accessibility branch from 2fc32d3 to a29ff3a Compare July 10, 2026 18:11
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.

1 participant