Skip to content

🎨 Palette: Fix screen reader announcement of flashcard hints#118

Draft
lavkushry wants to merge 1 commit into
mainfrom
palette-flashcard-a11y-15726032428437788866
Draft

🎨 Palette: Fix screen reader announcement of flashcard hints#118
lavkushry wants to merge 1 commit into
mainfrom
palette-flashcard-a11y-15726032428437788866

Conversation

@lavkushry

Copy link
Copy Markdown
Owner

💡 What

Replaced CSS pseudo-elements (::before and ::after) used for flashcard visual hints with explicitly injected DOM elements (divs).

🎯 Why

CSS pseudo-elements cannot be hidden from screen readers using aria-hidden. Because of this, screen readers were reading out the visual tap hints and checkmarks along with the actual flashcard content (e.g. reading "tap to flip Right Arrow" alongside the question text), creating a noisy and confusing experience for users.

📸 Before/After

Visually, the UI looks identical. The classes and CSS rules have simply been shifted to target the newly injected .flashcard__hint and .flashcard__seen-mark DOM elements rather than the pseudo-selectors.

♿ Accessibility

  • Explicitly injected div elements with aria-hidden="true".
  • Silenced redundant announcements of decorative icons and state hints while preserving the core flashcard question and answer content for screen readers.

PR created automatically by Jules for task 15726032428437788866 started by @lavkushry

Replaces the use of CSS pseudo-elements (`::before` and `::after`) for rendering flashcard UI hints (the "tap to flip" text and "seen" checkmark) with explicitly injected DOM `div` elements. Pseudo-elements cannot be individually hidden from screen readers, causing confusing and redundant announcements alongside flashcard content (e.g. "tap to flip Right Arrow"). The newly injected DOM elements correctly utilize `aria-hidden="true"`.

Co-authored-by: lavkushry <106930153+lavkushry@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.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 38489a99-cf8a-4229-b057-dc067ba74b02

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch palette-flashcard-a11y-15726032428437788866

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Copy link
Copy Markdown

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 updates the flashcard component to improve accessibility for screen readers. It replaces CSS pseudo-elements that injected text (the checkmark and the "tap to flip" hint) with actual DOM elements configured with aria-hidden="true", and documents this best practice in the palette guide. The reviewer suggests using span instead of div for these new elements to ensure semantic correctness for inline text.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread theme/visual-edition.js
Comment on lines +480 to +488
const seenMark = document.createElement("div");
seenMark.className = "flashcard__seen-mark";
seenMark.setAttribute("aria-hidden", "true");
seenMark.textContent = "✓";

const hint = document.createElement("div");
hint.className = "flashcard__hint";
hint.setAttribute("aria-hidden", "true");
hint.textContent = "tap to flip →";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using span instead of div is semantically more appropriate for inline text elements like the checkmark () and the tap hint (tap to flip →). Since these elements represent short, inline textual/symbolic hints rather than structural block-level sections, span is the standard choice. This change is fully compatible with the existing CSS styles.

Suggested change
const seenMark = document.createElement("div");
seenMark.className = "flashcard__seen-mark";
seenMark.setAttribute("aria-hidden", "true");
seenMark.textContent = "✓";
const hint = document.createElement("div");
hint.className = "flashcard__hint";
hint.setAttribute("aria-hidden", "true");
hint.textContent = "tap to flip →";
const seenMark = document.createElement("span");
seenMark.className = "flashcard__seen-mark";
seenMark.setAttribute("aria-hidden", "true");
seenMark.textContent = "✓";
const hint = document.createElement("span");
hint.className = "flashcard__hint";
hint.setAttribute("aria-hidden", "true");
hint.textContent = "tap to flip →";

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