# Cart Drawer Focus Traps: A Keyboard Check That Takes Five Minutes

Source: https://cartcomply.com/blog/2026-11-19-cart-drawer-focus-trap-keyboard-check.html

The shopper adds a jumper, the cart drawer slides in, and from that moment the keyboard stops working properly. Tab moves through the drawer items, then starts again at the top of the drawer, forever. There is no visible close button in the tab order, Escape does nothing, and the checkout button behind the overlay might as well be on another website. This failure takes five minutes to find and it is on a large share of the drawers we test.

## Run the five minute test in this order

Use only the keyboard. Tab to the add to cart button and press Enter. Note where focus lands: it should move into the drawer, ideally to the drawer heading or its close button. Keep tabbing and count the stops. A working drawer lets you reach the close button, the quantity controls, and checkout in a sane order, then either closes or moves focus onward deliberately. A broken drawer loops, loses focus to the page behind the overlay, or shows no visible focus indicator at all, which separately fails WCAG 2.4.7 Focus Visible.

The [WebAIM Million 2025 report](https://webaim.org/projects/million/) found detectable WCAG failures on 94.8 percent of the top million home pages, with an average of 51 errors per page. Cart drawers are not home pages, but the same pattern holds: interactive overlays built for the mouse first and the keyboard never.

## Escape and focus return are the two checks everyone skips

Press Escape with the drawer open. A drawer that does not close on Escape forces keyboard users to tab the full loop to find the close control. Then close the drawer properly and watch where focus goes. It should return to the add to cart button that opened it. If focus resets to the top of the page, a screen reader user loses their place in the product list and has to navigate back, product by product. WCAG 2.4.3 covers the order of that journey, and a focus reset breaks its intent even when every stop is technically reachable.

Our earlier check on [promo code field error association](2026-11-18-cart-promo-code-field-error-association.md) covered what happens inside a form field. The drawer is the same discipline one level up: every state change, open, close, quantity update, has to announce itself and put focus somewhere defensible.

## Fix order: trap first, polish later

Fix the trap before anything cosmetic. A drawer with a working close button in the tab order, Escape to close, and focus returned to the trigger passes the core requirement even if the focus styling is plain. Then add the visible focus indicator and check the drawer's heading is announced as a dialog to assistive technology. Record the test in your audit log with the keyboard path you took. A drawer fixed without a recorded path regresses at the next theme update, usually within a quarter.

Keep reading: [promo code field error association](2026-11-18-cart-promo-code-field-error-association.md), [gift card balance check accessible status](2026-11-18-gift-card-balance-check-accessible-status.md).

## Frequently asked questions

### How do I test a cart drawer with only a keyboard?

Tab to add to cart, press Enter, and keep tabbing through the drawer. You should reach the close button and checkout in a logical order, with a visible focus indicator throughout. Press Escape to close, and confirm focus returns to the button that opened the drawer.

### What WCAG rules does a broken cart drawer fail?

A drawer that traps focus fails 2.1.2 No Keyboard Trap. A drawer with an illogical tab order or a focus reset on close fails the intent of 2.4.3 Focus Order. A missing visible indicator fails 2.4.7 Focus Visible. Each is a Level A or AA criterion in WCAG 2.2.

### Should focus move into a cart drawer when it opens?

Yes. When a drawer opens in response to a keyboard action, focus should move into it, to the heading or close control, so keyboard and screen reader users know it appeared. Leaving focus on the page behind an overlay strands the user in content they can no longer see clearly.

### Does Escape have to close a cart drawer?

Escape to close is the expected behaviour for a dialog style overlay, and it is the fastest way to prove the drawer is not a trap. If Escape does nothing, make sure the close button is early in the tab order and clearly labelled, then add Escape handling at the next fix.
