- Success Criterion 2.1.2
- Conformance level A
Script That Yanks Focus Back Every Time the User Tabs Away
2.1.2 — No Keyboard Trap
Scenario
Setting
A job board's application form
What’s wrong
focus() handlers yanking focus back whenever the user tabs away (auto-refocus traps).
Example
On a job board's application form, a visitor hits this wall: focus() handlers yanking focus back whenever the user tabs away (auto-refocus traps).
Why it matters
All keyboard and screen-reader users who can become stuck inside a component. On a job board's application form, this barrier means they get stuck and can't reach the control.
How to test
Tab away from a control: if a focus() handler yanks focus back immediately, you're trapped in a loop and can never move past it.
How to fix
Focus must always be able to leave the component using Tab/Shift+Tab or Esc (or a standard method the user is told about).
Outcome
Corrected, a job board's application form now lets a visitor complete the task using only the keyboard.
Who is affected
All keyboard and screen-reader users who can become stuck inside a component.
Learn more
- Understanding Understanding document (opens in a new tab)
Related scenarios
- Keyboard Focus Stuck Inside an Embedded Plugin or Widget
- Modal Focus Trap With No Escape Key or Close Button
- Widget Where Tab Cycles Internally With No Way Out
- Third-Party Embed That Captures and Never Releases Tab Focus
- Rich Text Editor That Captures Tab With No Documented Escape
- Autocomplete List That Keeps Recapturing Focus on Every Blur