Keyboard traps
If focus cannot escape a component, keyboard users are stuck.
See this on your site
Step-by-step fixes by platform
Programmatic guides combine the issue explanation with stack-specific notes and examples where we have them.
Fixes
On open, move focus to the dialog; on close, restore focus. Escape should close when appropriate.
Examples
- Modal opens but focus stays on the background page.
- Custom dropdown captures Tab with no Escape to leave.
How to fix
On open, send focus to the first interactive control; on close, restore focus to the trigger.
Support Escape where users expect dismissal; document exceptions.
Platform notes
- React
- Prefer accessible dialog libraries or follow WAI-ARIA dialog pattern tests.
Related: 2.1.2 No Keyboard Trap.