A dialog keyboard users cannot leave
UI-INTERACT-03The form dialog does not keep focus inside it, so Tab walks into the page behind and screen readers lose their place.
components/InviteModal.tsx
Flagged
export function InviteModal() {
return (
<div role="dialog" aria-modal="true">
<input name="email" />
<input name="name" />
<input name="team" />
</div>
);
}
Passes
export function InviteModal() {
const onKey = (e: KeyboardEvent) => {
if (e.key !== 'Tab') return;
if (e.shiftKey && document.activeElement === first) { e.preventDefault(); last.focus(); }
};
return (
<div role="dialog" aria-modal="true" onKeyDown={onKey}>
<input name="email" />
<input name="name" />
<input name="team" />
</div>
);
}