🎨 Palette: Fix screen reader announcement of flashcard hints#118
🎨 Palette: Fix screen reader announcement of flashcard hints#118lavkushry wants to merge 1 commit into
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
| 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 →"; |
There was a problem hiding this comment.
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.
| 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 →"; |
💡 What
Replaced CSS pseudo-elements (
::beforeand::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__hintand.flashcard__seen-markDOM elements rather than the pseudo-selectors.♿ Accessibility
divelements witharia-hidden="true".PR created automatically by Jules for task 15726032428437788866 started by @lavkushry