CODAP-614: trap keyboard focus in user entry modal#2435
Conversation
Convert UserEntryModal from a plain div to Chakra Modal for proper focus trapping, overlay, and escape handling. Add focus-visible indicators to modal buttons. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR improves accessibility by converting the UserEntryModal from a custom div-based modal to using Chakra UI's Modal component. The change provides proper keyboard focus trapping, escape key handling, and better overlay management—replacing manual implementations with a well-tested library component.
Changes:
- Replaced custom div-based modal with Chakra Modal, ModalOverlay, and ModalContent components
- Removed manual keyboard event handling (Escape and Enter keys) in favor of Chakra's built-in behavior
- Added initialFocusRef to automatically focus the "Open Document" button when the modal opens
- Removed manual positioning CSS (position, top, left, transform, z-index) as Chakra handles this
- Added :focus-visible styling for clear keyboard navigation indicators
- Added border-radius to modal header to match Chakra's ModalContent rounded corners
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| v3/src/components/menu-bar/user-entry-modal.tsx | Converted to Chakra Modal with focus management; removed custom keyboard handlers and React import; added ref for default button focus |
| v3/src/components/menu-bar/user-entry-modal.scss | Removed positioning styles delegated to Chakra; added header border-radius and :focus-visible indicator styles |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2435 +/- ##
=======================================
Coverage 85.51% 85.51%
=======================================
Files 758 758
Lines 42086 42081 -5
Branches 10412 10420 +8
=======================================
- Hits 35990 35986 -4
+ Misses 6084 6080 -4
- Partials 12 15 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
codap-v3
|
||||||||||||||||||||||||||||
| Project |
codap-v3
|
| Branch Review |
main
|
| Run status |
|
| Run duration | 02m 19s |
| Commit |
|
| Committer | github-actions[bot] |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
4
|
| View all changes introduced in this branch ↗︎ | |
Add aria-labelledby to associate the dialog with its title, so screen readers announce "What would you like to do?" when the modal opens. Issue identified by accesslint accessibility audit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nd-drop Chakra Modal portals to document.body by default, which covered the user-entry-drop-overlay and broke file drag-and-drop on the user entry screen. Use containerRef to render the portal inside the overlay so drag events bubble to the drop handler correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Accessibility Audit (accesslint)An accessibility audit was run on the user entry modal. The migration to Chakra Modal is a net positive for accessibility, providing focus trapping, Fixed in this PR:
Pre-existing issues (not addressed in this PR):
These pre-existing contrast and layout issues could be addressed in a follow-up story. |
…d add tests Replace raw divs with Chakra ModalHeader and ModalBody so that aria-labelledby and aria-describedby are automatically wired up on the dialog element. Disable closeOnOverlayClick to match V2 behavior. Add unit tests for accessibility attributes, focus trapping, and modal interactions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
emcelroy
left a comment
There was a problem hiding this comment.
Looks good! (I was going to comment on the use of eslint-disable testing-library/no-node-access in the test file, but tried removing it myself and quickly realized why you opted to use it.)
Summary
Fixes CODAP-614
Test plan
Generated with Claude Code