The user wants a plan for a "focus management audit" to ensure a web application or site aligns with WAI-ARIA best practices. This involves checking three specific areas:
- Keyboard Flows: Can users navigate logically and efficiently using a keyboard?
- Aria-live Regions: Are dynamic changes announced correctly to screen reader users?
- Focus Traps: Are focus traps used correctly in modals/dialogs to prevent users from getting "lost"?
The goal is to create a structured approach (a plan) to audit these things.
Target Audience: Developers, QA testers, or accessibility specialists.
Tone: Professional, structured, actionable, and technical.
Key Components of the Plan:
- Preparation/Scope: What are we auditing? What tools do we need?
- Phase 1: Keyboard Navigation (The Foundation): Tab order, logical flow, shortcuts.
- Phase 2: Focus Traps (Modals/Overlays): Ensuring focus stays contained.
- Phase 3: Dynamic Content (Aria-live): Handling notifications and updates.
- Phase 4: Focus Indication (Visuals): Can users see where they are?
- Reporting/Remediation: How to document findings.
Drafting the Details:
- Preparation: Need a list of URLs/components, screen readers (NVDA, VoiceOver), and browser dev tools (Accessibility Insights, Axe).
- Keyboard Flow:
- Check tab order matches visual order (DOM order).
- Check custom widgets (menus, tabs, grids). Do they follow ARIA design patterns (arrow keys vs tab keys)?
- Check "skip links."
- Focus Traps:
- Identify all modals.
- Test the "loop" (Tab moves forward, Shift+Tab moves backward).
- Test the "close" mechanism (Escape key and close button should return focus to the trigger).
- Aria-live:
- Identify areas where content updates without reload (search results, toast notifications, form errors).
- Check
aria-live="polite" vs aria-atomic vs aria-relevant.
- Ensure screen readers actually hear the message.
- Visual Focus:
- Is the focus ring visible? High contrast?
- Are we removing outline without replacing it (a big no-no)?
Structuring the Output:
I'll organize this as a step-by-step Audit Plan with specific checklists for each section. I will also include a section on "Common Pitfalls" to watch out for, as that adds value.
Self-Correction during drafting: I initially forgot to emphasize focus restoration (sending focus back to the trigger element after a modal closes). I need to add that to the Focus Traps section. I also need to mention the difference between role="alert" and aria-live="assertive".
Refining the Plan:
- Executive Summary: Brief overview of the goal.
- Tools Required: Hardware/Software.
- Audit Modules:
- Module 1: Global Keyboard Flow (Sequential Navigation).
- Module 2: Complex Widgets & Patterns (Interaction).
- Module 3: Focus Containment (Modals/Traps).
- Module 4: Live Updates (Aria-live).
- Module 5: Visual Indicators.
- Reporting Template: What a bug report should look like.
Let's flesh out the specific ARIA best practices references.
- Keyboard: WCAG 2.1.1, 2.4.3.
- Traps: WCAG 2.4.3 (Focus Order).
- Live: WCAG 4.1.3 (Status Messages).
Let's generate the response based on this structure.
A Focus Management Audit ensures that interactive elements are reachable, usable, and understandable via keyboard and assistive technologies. This plan outlines a systematic approach to auditing keyboard flows, focus trapping, and live regions based on WAI-ARIA 1.2 and WCAG 2.1/2.2 standards.
Phase 1: Preparation & Tooling
Before beginning, define the scope and gather the necessary tools.
- Tools Required:
- Keyboard: Standard physical keyboard.
- Screen Readers: NVDA (Windows), VoiceOver (macOS/iOS), JAWS (Windows).
- Browser Dev Tools: Accessibility Inspector (Chrome/Firefox/Safari).
- Visual Indicators: Use a focus indicator extension (e.g., Focus Visible or browser "Show focus rings" setting) to make focus movement visible during testing.
- Scope Definition:
- Identify critical user flows (Login, Checkout, Dashboard navigation).
- Identify dynamic components (Modals, Slide-outs, Auto-suggest inputs, Tabs).
Phase 2: The Audit Modules
The audit is divided into three specific modules corresponding to your requirements.
Module 1: Keyboard Flow & Logical Navigation
Goal: Ensure the focus order matches the visual order and all interactive elements are accessible.
| Test Case | Action | Expected Result (WAI-ARIA Best Practice) |
|---|
| Sequential Navigation | Press Tab repeatedly through the page. | Focus moves left-to-right, top-to-bottom (DOM order matches visual order). |
| Focus Visibility | Navigate to all interactive elements. | A clear, high-contrast visual indicator is present on every focused element (never outline: none without replacement). |
| Hidden Elements | Check if items visually hidden (collapsed menus, tabs not active) are focusable. | Elements that are visually hidden should generally not be focusable (apply tabindex="-1" or aria-hidden="true"). |
| Custom Widgets | Test specific patterns (Tabs, Menus, Grids). | Follow specific key support (e.g., Tabs should use Arrow keys to switch tabs, not just Tab). Reference ARIA Authoring Practices Guide (APG). |
| Shortcuts | Test standard shortcuts (e.g., Enter to activate links/buttons). | Enter triggers buttons/links; Space triggers buttons/checkboxes. |
| Skip Links | Press Tab as soon as the page loads. | A "Skip to Main Content" link is the first focusable item and moves focus to the main content area. |
Module 2: Focus Traps & Containment
Goal: Ensure focus is contained within overlays and correctly restored when closed.
| Test Case | Action | Expected Result (WAI-ARIA Best Practice) |
|---|
| Modal Activation | Open a modal/lightbox via keyboard (Enter or Space). | Focus automatically moves to the modal container, the first interactive element, or a specific heading inside the modal. |
| The "Trap" | Press Tab repeatedly inside the modal. | Focus must cycle strictly within the modal (Last element → First element). Focus must never reach the background page. |
| Closing the Trap | Press Esc or activate the "Close" button. | The modal closes, and focus returns to the element that triggered the modal (the "trigger button"). |
| Nested Traps | Open a sub-menu or nested modal within a modal. | The trap tightens to the new context. When the sub-context closes, focus returns to the parent modal, not the background page. |
| Non-Modal Overlays | Open a chat widget or sticky sidebar. | While Tab may move to the browser UI, the overlay should have a distinct "close" mechanism, and focus should usually return to the trigger. |
Module 3: Aria-Live Regions & Dynamic Updates
Goal: Ensure dynamic changes (errors, search results, loading) are announced without stealing focus.
| Test Case | Action | Expected Result (WAI-ARIA Best Practice) |
|---|
| Status Messages | Trigger a success/error notification (e.g., "Settings Saved"). | The screen reader announces the text. The user's focus remains on the current location (focus is not moved). |
| Live Region Attributes | Inspect the HTML of the notification area. | It uses role="status" (polite) or role="alert" (assertive). |
| Polite vs. Assertive | Trigger an urgent error vs. a standard update. | Polite (aria-live="polite"): Waits for the user to pause typing. Assertive (aria-live="assertive"): Interrupts immediately (use sparingly). |
| Autocomplete / Search | Type into a search box that returns live results. | The number of results or the fact that results have changed is announced. Focus stays in the input box so the user can keep typing. |
| Atomic Updates | Inspect a region that updates partial data (e.g., a clock or stock ticker). | aria-atomic="true" is used if the entire region must be re-read, or false if only changed parts should be read. |
Phase 3: Specific Component Patterns (The Checklist)
Use this quick reference for common complex components.
-
Tabs:
-
Combo-box / Autocomplete:
-
Radio Group:
Phase 4: Reporting & Remediation
When documenting issues, categorize them by severity and technical requirement.
Report Template Example:
| Issue ID | Component | Severity | Current Behavior | Expected Behavior | Fix Strategy |
|---|
| A11y-01 | Login Modal | Critical | Tab focus escapes to background page. | Focus must trap inside modal until closed. | Implement JS focus loop + inert attribute on background. |
| A11y-02 | Search Form | High | Screen reader does not announce "No results found". | aria-live region must announce status. | Add <div aria-live="polite"> container for status messages. |
| A11y-03 | Dashboard Menu | Medium | Focus ring is light grey (low contrast). | Focus indicator must be clearly visible. | Increase CSS outline width and color contrast ratio. |
Summary Checklist for Developers
- Focusable: Can I get there with
Tab?
- Operable: Can I use it with
Enter/Space/Arrows?
- Visible: Can I see where I am?
- Contained: Am I stuck in the modal until I leave?
- Informed: Did the screen reader tell me what happened?