• 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