Skip to content

🎨 Palette: Add keyboard focus indicators to confirmation dialogs#563

Open
aafre wants to merge 1 commit into
mainfrom
palette-responsive-confirm-dialog-a11y-1778306127933000535
Open

🎨 Palette: Add keyboard focus indicators to confirmation dialogs#563
aafre wants to merge 1 commit into
mainfrom
palette-responsive-confirm-dialog-a11y-1778306127933000535

Conversation

@aafre
Copy link
Copy Markdown
Owner

@aafre aafre commented May 30, 2026

💡 What: Added proper focus-visible states to action buttons in ResponsiveConfirmDialog. Also added the explicit type="button" attribute.
🎯 Why: To improve keyboard accessibility. Custom styled Tailwind buttons often lose their native browser focus outline, making it difficult or impossible for keyboard users to navigate modal actions.
Accessibility:

  • Added focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 to all action and close buttons.
  • Styled destructive confirm buttons with focus-visible:ring-red-500 and normal actions with focus-visible:ring-accent.
  • Added type="button" to ensure screen readers properly announce the elements and to prevent unintended form submissions.

PR created automatically by Jules for task 1778306127933000535 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 improves button accessibility in the ResponsiveConfirmDialog component by adding explicit button types and focus-visible Tailwind styles, and documents this learning in .jules/palette.md. The review feedback points out a critical accessibility issue: the modal currently lacks a focus trap, allowing keyboard users to tab out of the dialog. It is recommended to refactor the component using Headless UI's Dialog or to implement a custom focus trap.

Comment on lines 121 to 129
<button
type="button"
onClick={onClose}
disabled={isLoading}
className="w-full lg:w-auto px-6 py-3 border border-gray-300 rounded-lg font-medium text-gray-700
hover:bg-gray-50 active:bg-gray-100
transition-colors disabled:opacity-50 disabled:cursor-not-allowed
focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2
min-h-[48px] lg:min-h-[44px]"
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.

high

While adding focus-visible styles to the buttons is a great improvement for keyboard navigation, this modal currently lacks a focus trap. Without a focus trap, keyboard users can tab out of the modal into the background page, which violates accessibility standards (WCAG 2.1) and our general rules.

Since @headlessui/react is already a dependency in this project (used in TabbedHelpModal.tsx), we highly recommend refactoring this component to use Headless UI's Dialog (or FocusTrap), which automatically handles focus trapping, accessibility attributes, and backdrop behavior out of the box.

Alternatively, you can implement a custom focus trap using a useEffect hook and a useRef on the dialog container to intercept the Tab key and wrap focus between the first and last focusable elements.

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.

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