Web Accessibility & WCAG (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)
Custom Focus Management in Single Page Applications (SPAs).
senior LevelCode ExampleSystem Design
In Simple Words:
In traditional websites, full page navigation reloads the document, placing screen reader focus at the top (<title>).
In SPAs (React, Next.js, Vue), client-side route transitions swap the DOM silently. Screen reader focus is stranded!
- SPA Routing Focus Fix:
- On route change, update document
<title>. - Move focus programmatically to the main heading (
<h1>) or<main>container:javascriptdocument.getElementById('main-heading')?.focus(); - Emit an announcement via an
aria-liveregion: "Navigated to Dashboard page".
- On route change, update document