Reviewed November 18, 2026
Keyboard Traps Hide in Menus and Modals, Not in Your Checkout Form
A focus trap is only correct inside a modal dialog. Everywhere else on a storefront, focus that cannot escape is a keyboard failure under WCAG 2.1.2, No Keyboard Trap, a Level A criterion. The repeat offenders are familiar: mega menus that open on focus and swallow the tab order, cookie banners with no keyboard exit, chat widgets that capture focus and return nothing, and modal dialogs that forget to hand focus back to the control that opened them when they close. Each one strands a keyboard user mid journey.
The rule and its one exception
Criterion 2.1.2 says that if focus can move to a component, it must be able to move away using only the keyboard, and if leaving requires anything more than Tab or arrow keys, the user must be told how. The modal dialog is the designed exception that proves the reading: trapping focus inside an open dialog is correct, because the dialog is the task, and the exit is built into it, Escape, a close button, or completing the action. The failure is never the cycling itself. The failure is a cycle with no door.
Stores rarely write a trap on purpose. They assemble one. A menu plugin that manages focus aggressively, a consent tool injected late in the page, a chat widget with its own keyboard handling, and a quick view modal from a different developer each behave plausibly alone. Stacked in one header, their focus handling collides, and the seam between two components is exactly where a keyboard user gets stuck while every individual vendor insists their widget tested fine.
The four places to check first
Mega menus lead the list. A menu that opens on focus and intercepts Tab to keep users inside its columns, without Escape closing it and returning focus to the menu button, traps everyone who tabs into the navigation. Consent banners follow: a banner whose buttons are reachable but which reasserts focus, or which cannot be dismissed by keyboard at all, blocks the entire page beneath it. Chat widgets are third, especially ones that pull focus on load or on a proactive popup and offer no keyboard route back to the page.
Modals close the list, at the moment they close. A quick view or cart drawer that returns focus to the top of the document, or to nothing, forces a keyboard user to tab through the whole header again to resume shopping. It is not a hard trap under the criterion's wording, but it is the same family of failure: focus management written for how the page looks, not for how it is operated sequentially.
Fixing in the order users hit them
Work in journey order. Navigation first, because every keyboard session starts there: Escape closes menus, focus returns to the control that opened them, and Tab moves past a closed menu without entering it. Consent next: reachable, dismissible, and gone for good once dismissed. Then every dialog and drawer on the buying path, checking both the trap while open and the focus return on close. Test each third party widget in isolation before it ships. A store is the sum of its components' keyboard behavior, and 2.1.2 is the criterion that grades the sum, not the parts.
Related reading
Related reading on this site: Error Identification at Checkout: Say What Is Wrong, Where, in Words, WCAG 2.5.7 Dragging Movements: Every Drag on Your Store Needs a Click Alternative.
Frequently asked questions
Is a focus trap ever the correct behavior?
Inside a modal dialog, yes, and it is required behavior: while the dialog is open, focus cycles within it so keyboard users cannot tab into the obscured page behind. The trap becomes a violation when it has no exit. A modal must close with Escape or its close control and return focus to the element that opened it. A menu or banner that cycles focus forever with no way out fails 2.1.2 outright.
How do I test for keyboard traps on my store?
Keyboard only, no mouse. Tab forward through the header, menu, banners, and any dialog, then Shift Tab back. If you reach a component you cannot leave using Tab, Shift Tab, arrow keys, or Escape, you have found a trap. Also open and close every dialog and confirm focus returns to the button or link that opened it, rather than resetting to the top of the page.
Why do keyboard traps matter if mouse users are fine?
A mouse user can click anywhere else on the page, so a trap is invisible to them. Keyboard, switch device, and voice control users move sequentially through focusable elements, so a component that captures focus ends their session on your site. That asymmetry is why traps survive design reviews: everyone testing with a mouse sails straight past them.
Who is responsible when a third party widget traps focus?
Most are component configuration or theme code, not platform limits. Menus should close on Escape and return focus, banners need a keyboard reachable dismiss control, and third party widgets should be tested before they are installed and replaced if they trap. Where a vendor widget is the offender, the obligation is still yours; choosing a compliant widget or removing it is the fix.