fix(ui): add focus management to the shared Modal#370
Conversation
The shared Modal had dialog roles and Escape, but it never moved focus into the dialog, didn't trap Tab (so keyboard focus wandered onto the page behind it), and didn't return focus to the trigger on close. Since most modals reuse this primitive, that gap repeated everywhere. Move focus to the first field on open, trap Tab/Shift+Tab within the dialog, restore focus to the previously focused element on close, and give the title a unique id for aria-labelledby (instead of a shared static one). Closes Devlaner#347 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The shared
Modalhadrole="dialog",aria-modaland Escape handling, but it never moved focus into the dialog, didn't trap Tab (keyboard focus could land on the page behind it), and didn't return focus to the trigger on close. Most modals reuse this primitive, so the gap repeated everywhere.Linked issues
Closes #347
Type of change
fix:)Surface
apps/web/)What changed
Tab/Shift+Tabwithin the dialog.useId()foraria-labelledbyinstead of a shared staticmodal-titleid (which would collide if two modals ever mounted).Scope note
Issue #347 also lists the bespoke page-editor dropdowns and the inline confirm dialog in
IssueDetailPage. This PR fixes the sharedModal, which is the widest-reaching piece; the dropdowns/inline dialog are worth a follow-up (they don't share this primitive).Test plan
npm run typecheck+npm run lintpassAI assistance
Claude Code (Opus 4.8), commits carry aCo-Authored-By:trailer