Skip to content

🎨 Palette: Improve notification close button accessibility and focus styles#954

Open
anchapin wants to merge 2 commits intomainfrom
palette-notification-focus-a11y-1325480363428169002
Open

🎨 Palette: Improve notification close button accessibility and focus styles#954
anchapin wants to merge 2 commits intomainfrom
palette-notification-focus-a11y-1325480363428169002

Conversation

@anchapin
Copy link
Copy Markdown
Owner

@anchapin anchapin commented Apr 3, 2026

💡 What:

Improved the accessibility and focus styling of the notification close button. Added a title attribute for native tooltips, wrapped the decorative "✕" character in an aria-hidden span to prevent redundant screen reader announcements, and updated the CSS to use :focus-visible instead of :focus.

🎯 Why:

To provide a better micro-UX for all users. Mouse users will no longer see unnecessary focus rings when clicking notification buttons, and screen reader users will have a cleaner experience without redundant character announcements. The native tooltip provides immediate clarity for visual users.

♿ Accessibility:

  • Prevented redundant screen reader announcements by hiding the "✕" character.
  • Improved visual focus indicators by restricting them to keyboard navigation (:focus-visible).

PR created automatically by Jules for task 1325480363428169002 started by @anchapin

Summary by Sourcery

Improve accessibility and focus behavior for the notification close button and document the pattern in the Palette guidelines.

Enhancements:

  • Update notification action and close buttons to use :focus-visible for keyboard-only focus outlines.
  • Add a title tooltip and hide the decorative close icon from screen readers on the notification close button.
  • Document best practices for decorative characters in icon-only buttons and focus-visible usage in the Palette accessibility guide.

…styles

- Replaced `:focus` with `:focus-visible` for notification buttons to reduce visual noise for mouse users.
- Added `title="Close"` and `aria-hidden="true"` to the decorative '✕' character to improve screen reader experience and provide a native tooltip.

Co-authored-by: anchapin <6326294+anchapin@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.

Copilot AI review requested due to automatic review settings April 3, 2026 23:23
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 3, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Improves the notification close button’s accessibility and focus UX by adding a native tooltip, hiding the decorative “✕” from assistive tech, and updating focus styles to use :focus-visible. Also documents these accessibility learnings in the Palette guide.

File-Level Changes

Change Details Files
Improve accessibility and UX of the notification close button in the notification system component.
  • Add a title attribute ("Close") to the notification close button to provide a native tooltip for visual users.
  • Wrap the decorative "✕" character inside the close button in a to prevent redundant screen reader announcements while relying on the existing aria-label.
  • Keep the existing aria-label ("Close notification") so assistive technologies receive a descriptive control name.
frontend/src/components/NotificationSystem/NotificationSystem.tsx
Adjust focus styling for notification buttons to only show outlines for keyboard navigation.
  • Replace :focus with :focus-visible for .notification-action-btn and .notification-close-btn rules so focus outlines appear only when appropriate (e.g., keyboard focus).
  • Retain the 2px solid #667eea outline and 2px outline-offset to preserve accessible visual focus indicators.
frontend/src/components/NotificationSystem/NotificationSystem.css
Capture the new accessibility guidance for decorative characters and focus styling in the Palette documentation.
  • Add a new dated entry describing issues caused by decorative characters like "✕" in icon-only buttons that already have aria-labels.
  • Document the recommendation to wrap decorative characters in and to use :focus-visible instead of :focus for interactive elements.
.Jules/palette.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider adding a graceful fallback for browsers that don’t support :focus-visible (e.g., using :focus:not(:focus-visible) or a polyfill) so keyboard users still get a visible focus outline everywhere.
  • The title="Close" string is currently hardcoded; if the rest of the UI is localized, it would be better to source this from your i18n layer to keep tooltip text consistent across languages.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider adding a graceful fallback for browsers that don’t support `:focus-visible` (e.g., using `:focus:not(:focus-visible)` or a polyfill) so keyboard users still get a visible focus outline everywhere.
- The `title="Close"` string is currently hardcoded; if the rest of the UI is localized, it would be better to source this from your i18n layer to keep tooltip text consistent across languages.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the accessibility and keyboard-focus styling of the notification close button in the frontend notification/toast system.

Changes:

  • Adds a native tooltip (title) and hides the decorative “✕” from screen readers via aria-hidden.
  • Updates notification button focus styling to use :focus-visible instead of :focus.
  • Records the accessibility learning in the project’s palette log.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
frontend/src/components/NotificationSystem/NotificationSystem.tsx Updates the close button markup for improved screen reader behavior and tooltip support.
frontend/src/components/NotificationSystem/NotificationSystem.css Adjusts focus styles to be keyboard-intent-based via :focus-visible.
.Jules/palette.md Documents the accessibility rationale and styling guidance.

Comment on lines +284 to 287
.notification-action-btn:focus-visible,
.notification-close-btn:focus-visible {
outline: 2px solid #667eea;
outline-offset: 2px;
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

Switching these component-specific styles to :focus-visible doesn't prevent focus rings on mouse click because a global button:focus rule still applies (see frontend/src/index.css where button:focus sets an outline). As a result, .notification-*-btn will still show an outline on mouse focus in browsers where :focus-visible is not active. Consider adding a .notification-*-btn:focus:not(:focus-visible) rule (or an @supports selector(:focus-visible) block) to suppress mouse-focus outlines while preserving a keyboard-focus fallback.

Suggested change
.notification-action-btn:focus-visible,
.notification-close-btn:focus-visible {
outline: 2px solid #667eea;
outline-offset: 2px;
@supports selector(:focus-visible) {
.notification-action-btn:focus-visible,
.notification-close-btn:focus-visible {
outline: 2px solid #667eea;
outline-offset: 2px;
}
.notification-action-btn:focus:not(:focus-visible),
.notification-close-btn:focus:not(:focus-visible) {
outline: none;
}

Copilot uses AI. Check for mistakes.
className="notification-close-btn"
onClick={handleRemove}
aria-label="Close notification"
title="Close"
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

The title tooltip text (“Close”) is inconsistent with the accessible name (aria-label="Close notification"). For consistency (and to avoid potentially confusing mixed announcements in some assistive tech), consider aligning the title value with the aria-label (or dropping title if you don’t want a tooltip).

Suggested change
title="Close"
title="Close notification"

Copilot uses AI. Check for mistakes.
## 2024-06-13 - [Accessibility] Screen readers pronouncing decorative emojis
**Learning:** Screen readers often misinterpret standalone emojis (e.g., ⬇️, 🗑️) inside buttons, reading them literally, which creates redundant or confusing announcements when a descriptive `aria-label` is already present.
**Action:** Always wrap non-informational emojis or text-based icons in `<span aria-hidden="true">` when the parent interactive element already has a sufficiently descriptive label.
## 2025-04-03 - Improved Notification Close Button Accessibility and Focus Styles
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This new palette entry date looks off relative to the PR date (<current_datetime> is 2026-04-03). If this entry is meant to reflect this change, update the heading date accordingly to avoid a misleading historical log.

Suggested change
## 2025-04-03 - Improved Notification Close Button Accessibility and Focus Styles
## 2026-04-03 - Improved Notification Close Button Accessibility and Focus Styles

Copilot uses AI. Check for mistakes.
…styles

- Replaced `:focus` with `:focus-visible` for notification buttons to reduce visual noise for mouse users.
- Added `title="Close"` and `aria-hidden="true"` to the decorative '✕' character to improve screen reader experience and provide a native tooltip.
- Formatted modified files using pnpm prettier.

Co-authored-by: anchapin <6326294+anchapin@users.noreply.github.com>
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.

2 participants