A
keyboard trap
occurs when keyboard focus enters a UI region — such as a modal, dialog, or embedded widget — but cannot leave it using standard keyboard navigation (Tab, Shift+Tab, Esc). This is a critical
WCAG 2.1.2
violation because users who rely on keyboards (screen reader users, power users with mobility impairments) become stuck, unable to reach the rest of the page.
In this challenge, you are given a login form rendered inside a modal overlay. Currently, pressing Tab cycles through the form fields but the focus
escapes
behind the modal onto page elements your users cannot see or interact with. Your job is to trap the Tab cycle inside the modal and make sure the form is usable entirely by keyboard.
This is a common real-world pattern you will encounter in design systems, dialog components, slide-out drawers, and date picker overlays.