🎨 Palette: Add accessibility attributes to Duplicate and Upload modals#506
🎨 Palette: Add accessibility attributes to Duplicate and Upload modals#506aafre wants to merge 1 commit into
Conversation
Co-authored-by: aafre <8656674+aafre@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request enhances the accessibility of the DuplicateResumeModal and UploadResumeModal components by adding ARIA attributes, backdrop click-to-close functionality, and 'Escape' key support. Feedback focuses on optimizing the 'Escape' key event listener to only attach when the modal is active, implementing a focus trap for both modals to meet accessibility requirements, and ensuring UploadResumeModal includes the same interaction improvements as the duplicate modal.
| useEffect(() => { | ||
| const handleKeyDown = (e: KeyboardEvent) => { | ||
| if (e.key === 'Escape' && isOpen) { | ||
| onCancel(); | ||
| } | ||
| }; | ||
| document.addEventListener('keydown', handleKeyDown); | ||
| return () => document.removeEventListener('keydown', handleKeyDown); | ||
| }, [isOpen, onCancel]); |
There was a problem hiding this comment.
The keydown event listener is currently attached to the document even when the modal is closed (since the component remains mounted but returns null at line 37). It is more efficient to only attach the listener when isOpen is true.
| useEffect(() => { | |
| const handleKeyDown = (e: KeyboardEvent) => { | |
| if (e.key === 'Escape' && isOpen) { | |
| onCancel(); | |
| } | |
| }; | |
| document.addEventListener('keydown', handleKeyDown); | |
| return () => document.removeEventListener('keydown', handleKeyDown); | |
| }, [isOpen, onCancel]); | |
| useEffect(() => { | |
| if (!isOpen) return; | |
| const handleKeyDown = (e: KeyboardEvent) => { | |
| if (e.key === 'Escape') { | |
| onCancel(); | |
| } | |
| }; | |
| document.addEventListener('keydown', handleKeyDown); | |
| return () => document.removeEventListener('keydown', handleKeyDown); | |
| }, [isOpen, onCancel]); |
| <div | ||
| className="bg-white rounded-lg shadow-xl max-w-md w-full mx-4" | ||
| onClick={(e) => e.stopPropagation()} | ||
| role="dialog" |
There was a problem hiding this comment.
This modal is missing a focus trap, which is required by the general rules to ensure keyboard focus remains within the modal's focusable elements while it is open. This prevents users from accidentally tabbing out of the modal into the background content.
References
- For accessibility, all modals must implement a focus trap to ensure keyboard focus remains within the modal's focusable elements while it is open.
| <button | ||
| onClick={handleCloseModal} | ||
| className="text-white/80 hover:text-white transition-colors" | ||
| aria-label="Close dialog" |
There was a problem hiding this comment.
While adding aria-label to the close button is a good improvement, this modal is still missing several critical accessibility and UX features that were implemented in DuplicateResumeModal.tsx in this PR. To ensure consistency and full accessibility, please consider adding:
role="dialog"andaria-modal="true"to the modal container.aria-labelledbylinked to the modal title.Escapekey support to close the modal.- 'Click outside to close' functionality on the backdrop.
- A focus trap (as required by the repository rules).
References
- For accessibility, all modals must implement a focus trap to ensure keyboard focus remains within the modal's focusable elements while it is open.
|
Closing duplicate — the most recent version of this change is PR #533. |
Understood. Acknowledging that this work is a duplicate and stopping work on this task. |
aria-labelto the close button inUploadResumeModal.tsx. Addedrole="dialog",aria-modal="true",aria-labelledby, andEscapekey support toDuplicateResumeModal.tsx.Escapekey support to close the modal.PR created automatically by Jules for task 12082853777398001689 started by @aafre