Focus Trap
When the modal is open and I press Tab, keyboard focus wanders behind the dimmed backdrop—and disappears when I close it.
Tab and Shift+Tab without leaking behind the backdrop, and return to the original trigger button on Escape or close. Focus traps belong strictly to blocking modal overlays—never to non-modal tooltips or persistent sidebars where users must stay free to reach the rest of the page.You can say this to an AI Agent
Ready to paste into Cursor, Claude Code, or CodexAdd a complete focus trap and focus restoration to this modal: move focus inside the dialog when it opens, wrap `Tab` and `Shift+Tab` strictly within the dialog so background links cannot be focused, and restore focus to the original trigger button on `Escape` or close (prefer native `<dialog>.showModal()` or an accessible dialog primitive). Verify open, Tab cycling, and Escape close using the keyboard only.
