Skip to content

🎨 Palette: Improve AuthModal accessibility and keyboard navigation#548

Open
aafre wants to merge 1 commit into
mainfrom
palette/auth-modal-a11y-16116905777940714228
Open

🎨 Palette: Improve AuthModal accessibility and keyboard navigation#548
aafre wants to merge 1 commit into
mainfrom
palette/auth-modal-a11y-16116905777940714228

Conversation

@aafre
Copy link
Copy Markdown
Owner

@aafre aafre commented May 23, 2026

What: Added Escape key functionality to close the AuthModal, added role="dialog" and aria-modal="true", and improved the focus visibility on the close button.
Why: To ensure users relying on keyboards and screen readers can properly interact with and dismiss the authentication modal.
Before/After: The modal now correctly acts as an accessible dialog and closes on Escape. The close button shows a clear focus ring.
Accessibility: Added standard dialog ARIA attributes and a visible focus ring to the icon-only close button.


PR created automatically by Jules for task 16116905777940714228 started by @aafre

Co-authored-by: aafre <8656674+aafre@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the accessibility of the AuthModal component by implementing an Escape key listener, adding standard ARIA attributes (role, aria-modal, aria-labelledby), and improving focus styles for the close button. It also updates the project's accessibility guidelines in palette.md. The review feedback points out that a focus trap is still missing in the modal implementation, which is necessary to prevent keyboard users from navigating outside the dialog while it is active, and suggests updating the documentation to include this requirement.

Comment on lines +65 to +79
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
onClose();
}
};

if (isOpen) {
window.addEventListener('keydown', handleKeyDown);
}

return () => {
window.removeEventListener('keydown', handleKeyDown);
};
}, [isOpen, onClose]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While adding the Escape key listener is a significant improvement for accessibility, the repository's general rules require all modals to implement a focus trap. This ensures that keyboard focus remains within the modal's focusable elements while it is open, preventing users from accidentally tabbing out of the dialog into the background content.

References
  1. For accessibility, all modals must implement a focus trap to ensure keyboard focus remains within the modal's focusable elements while it is open.

Comment thread .Jules/palette.md

## 2025-02-14 - Modal Keyboard Accessibility and Escape Key
**Learning:** Custom modals like `AuthModal.tsx` initially lacked basic modal behavior traits, such as listening for the `Escape` key and standard ARIA attributes (`role="dialog"`, `aria-modal="true"`, `aria-labelledby`). Additionally, the `MdClose` icon buttons in such modals frequently missed keyboard focus styles.
**Action:** When implementing or updating custom modals, always attach a `keydown` event listener via `useEffect` to handle the `Escape` key for closure. Add `role="dialog"`, `aria-modal="true"`, and link titles using `aria-labelledby`. Ensure all icon-only action buttons use `focus:outline-none focus-visible:ring-2` to provide clear feedback to keyboard users.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The action item should be updated to include the requirement for implementing a focus trap in custom modals, ensuring consistency with the repository's general accessibility rules.

Suggested change
**Action:** When implementing or updating custom modals, always attach a `keydown` event listener via `useEffect` to handle the `Escape` key for closure. Add `role="dialog"`, `aria-modal="true"`, and link titles using `aria-labelledby`. Ensure all icon-only action buttons use `focus:outline-none focus-visible:ring-2` to provide clear feedback to keyboard users.
Action: When implementing or updating custom modals, always attach a keydown event listener via useEffect to handle the Escape key for closure and implement a focus trap. Add role="dialog", aria-modal="true", and link titles using aria-labelledby. Ensure all icon-only action buttons use focus:outline-none focus-visible:ring-2 to provide clear feedback to keyboard users.
References
  1. For accessibility, all modals must implement a focus trap to ensure keyboard focus remains within the modal's focusable elements while it is open.
  2. Ensure documentation, such as testing plans, is updated to reflect UI and implementation changes made in the same pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant