Home
Bookmarks
Leagues
LEARN
Courses
Career Paths
Assessments
Tutorials
Arcade
Glossary
GROW
Certifications
Log in
Glossary
Log inSign up
Courses/Introduction to Design Systems/Accessibility First: WCAG & Inclusive Foundations/
Exercise #5

Focus Trapping in Modals & Dialogs

When a modal dialog or drawer opens, it demands the user's immediate attention. If focus is not managed properly, two severe accessibility bugs occur:

  1. Leaking Focus: Pressing Tab cycles behind the modal into the obscured background page, confusing screen reader and keyboard users.
  2. Lost Focus on Close: When the modal closes, focus resets to the top <body> tag rather than returning to the button that triggered the modal.

A governed modal component must implement a Focus Trap:

  • When opened, focus shifts automatically to the modal's primary heading or first interactive control.
  • Pressing Tab on the last interactive element wraps focus back to the first element in the modal.
  • Pressing Escape closes the modal immediately and restores focus to the triggering element.

Topics

Accessibility as a Systemic Multiplier
The 4 Core Principles of WCAG (POUR)
Color Contrast Standards: WCAG AA vs AAA
Visible Focus Rings & Focus Management
Focus Trapping in Modals & Dialogs
ARIA: When to Use It and the 'First Rule of ARIA'
Touch Targets & Pointer Cancellation (WCAG 2.2)
Motion Sensitivity & `prefers-reduced-motion`
Screen Reader Testing & Semantic Landmarks
Challenge: Auditing an Inaccessible Form Field

From lesson

2

Accessibility First: WCAG & Inclusive Foundations

Level 2 · Core Principles & Governance

Top contributors

Community contribution details will appear here once real learner activity is available.

Share