Skip to content

🎨 Palette: [Accessibility] Improve LinkInsertionModal screen reader & keyboard support#383

Closed
aafre wants to merge 1 commit into
mainfrom
palette/link-modal-a11y-17592977304736610285
Closed

🎨 Palette: [Accessibility] Improve LinkInsertionModal screen reader & keyboard support#383
aafre wants to merge 1 commit into
mainfrom
palette/link-modal-a11y-17592977304736610285

Conversation

@aafre
Copy link
Copy Markdown
Owner

@aafre aafre commented Mar 11, 2026

💡 What: Improved screen reader and keyboard accessibility for the LinkInsertionModal.
🎯 Why: Custom modals can break accessibility tools if they do not declare themselves as dialogs, fail to link their input fields explicitly to labels, or omit focus rings for keyboard users.
Accessibility:

  • Applied role="dialog" and aria-modal="true".
  • Associated inputs with labels using id / htmlFor.
  • Enforced focus-visible states on interactive buttons.

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

… keyboard support

- Add explicit `role="dialog"`, `aria-modal="true"`, and `aria-labelledby` attributes to modal container.
- Semantically link `<label>` text to `<input>` tags using explicit `id` and `htmlFor`.
- Add `type="button"` and `focus-visible` utility classes to action buttons to ensure clear keyboard navigability.

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.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the accessibility of the LinkInsertionModal component. The changes ensure that users relying on screen readers and keyboard navigation have a more robust and intuitive experience when interacting with the modal, addressing common accessibility pitfalls in custom UI components.

Highlights

  • Enhanced Screen Reader Support: The LinkInsertionModal now explicitly declares itself as a dialog using role="dialog" and aria-modal="true", and its title is linked via aria-labelledby for better context for screen reader users.
  • Improved Keyboard Navigation: Input fields are now explicitly associated with their labels using id and htmlFor attributes, and interactive buttons have focus-visible states enforced to provide clear visual feedback for keyboard users.
  • Accessibility Documentation Added: A new markdown file has been added to document the accessibility findings and best practices for custom modals, serving as a learning resource for future development.
Changelog
  • .Jules/palette.md
    • Added a new markdown file documenting accessibility findings and recommended actions for custom modals, specifically referencing the LinkInsertionModal.
  • resume-builder-ui/src/components/LinkInsertionModal.tsx
    • Updated string literals from single quotes to double quotes for consistency.
    • Applied role="dialog", aria-modal="true", and aria-labelledby="link-modal-title" to the modal's main container for improved screen reader interpretation.
    • Assigned an id to the modal's title (h3) and linked it using aria-labelledby.
    • Explicitly associated input fields ('Link Text' and 'URL') with their respective labels by adding id attributes to inputs and htmlFor attributes to labels.
    • Added focus-visible:outline-none to input fields to manage focus styling.
    • Set type="button" for all interactive buttons within the modal for semantic correctness.
    • Implemented focus-visible:ring-2 focus-visible:ring-offset-2 utility classes on buttons to enhance visual focus indication for keyboard users.
Activity
  • The pull request was automatically created by Jules for task 17592977304736610285, initiated by @aafre.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 makes good progress on improving the accessibility of the LinkInsertionModal by adding necessary ARIA roles and properties, associating labels with inputs, and adding visible focus states. However, it's missing a critical accessibility feature for modals: focus trapping. Without it, keyboard users can navigate outside the modal, leading to a confusing experience. I've left a comment with details on how to implement this. I've also suggested updating the associated learnings document to include focus trapping as a requirement for accessible modals.

Comment on lines +107 to +109
role="dialog"
aria-modal="true"
aria-labelledby="link-modal-title"
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 role="dialog" and aria-modal="true" is a great step for accessibility, it's incomplete without implementing focus trapping. An accessible modal dialog must prevent keyboard focus from leaving the modal.

When aria-modal="true" is set, assistive technologies expect focus to be contained. Currently, a user can tab out of the modal to the underlying page, which is a confusing experience and fails WCAG guidelines.

To fix this, you need to implement focus trapping. When the modal is open, tabbing should cycle through the modal's interactive elements only. You can achieve this by:

  1. Finding all focusable elements within the modal.
  2. On Tab keydown, if focus is on the last element, move it to the first.
  3. On Shift+Tab keydown, if focus is on the first element, move it to the last.

Consider using a library like focus-trap-react to simplify this, or add the logic manually within a useEffect hook.

Comment thread .Jules/palette.md

## 2025-05-18 - LinkInsertionModal Accessibility Findings
**Learning:** Custom modals like `LinkInsertionModal` were missing explicit screen reader attributes (`role="dialog"`, `aria-modal="true"`, `aria-labelledby`), unlinked form inputs (`id` to `htmlFor`), and explicit `focus-visible` states on their action buttons. This causes screen readers to misidentify the scope and keyboard users to lose track of focus.
**Action:** When building custom modals, always enforce explicit `role="dialog"`, `aria-modal="true"`, explicitly link `<label>` tags with input `id`s, and add `focus-visible:ring-2` to all action buttons to ensure robust screen reader and keyboard accessibility.
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

This is a great summary of learnings. To make it more complete and ensure future modals are fully accessible, I'd suggest adding 'focus trapping' to the list of required actions.

Suggested change
**Action:** When building custom modals, always enforce explicit `role="dialog"`, `aria-modal="true"`, explicitly link `<label>` tags with input `id`s, and add `focus-visible:ring-2` to all action buttons to ensure robust screen reader and keyboard accessibility.
**Action:** When building custom modals, always enforce explicit 'role="dialog"', 'aria-modal="true"', trap focus within the modal, explicitly link 'label' tags with input 'id's, and add 'focus-visible:ring-2' to all action buttons to ensure robust screen reader and keyboard accessibility.
References
  1. Ensure documentation, such as testing plans, is updated to reflect UI and implementation changes made in the same pull request.

@aafre
Copy link
Copy Markdown
Owner Author

aafre commented Apr 11, 2026

Closing: LinkInsertionModal a11y was already merged via #381 (PR #338). See #457 for the consolidated Jules batch-2 PR.

@aafre aafre closed this Apr 11, 2026
@google-labs-jules
Copy link
Copy Markdown
Contributor

Closing: LinkInsertionModal a11y was already merged via #381 (PR #338). See #457 for the consolidated Jules batch-2 PR.

Understood. Acknowledging that this work is now obsolete and stopping work on this task.

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