feat: improve screen reader accessibility and Keyword aria-attributes #18
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
javascript
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
thayen/portfolio-site!18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/accessibility-enhancements-14425787500875457532"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR implements the requested screen reader accessibility enhancements:
Keywordcomponent now correctly uses thearia-describedbyattribute to link the main visible text with its hidden expositional tooltip content, enabling the "informational approach" requested.role="tooltip"has been added for explicit semantic correctness.index.astro(Skills, Experience, Education) now act as proper, labeled landmark sections by usingaria-labelledbytied to their respective headers, aiding overall site navigation for screen reader users.PR created automatically by Jules for task 14425787500875457532 started by @N0tAI
👋 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.
Code Review
This pull request improves accessibility by adding ARIA attributes to sections and keyword tooltips. The review feedback suggests using crypto.randomUUID() for more robust ID generation and adding a semantic role to the focusable keyword span to better support screen readers.
@ -2,0 +2,4 @@import crypto from "node:crypto";import type { HTMLAttributes } from 'astro/types';type AriaRole = HTMLAttributes<'div'>['role'];Using
Math.random()for ID generation can lead to collisions or inconsistent ID lengths. Since this code runs in a Node environment (Astro frontmatter),crypto.randomUUID()is a more robust and standard way to generate unique identifiers.The
spanelement is focusable viatabindex, but it lacks a semantic ARIA role. When an element is part of the tab order, screen readers expect a role to describe its purpose. Addingrole="term"correctly identifies this as a word or phrase with an associated definition (the tooltip).@jules
Please refactor the id string to use
crypto.randomUUIDinstead of math.random for better collision avoidance.I have updated
Keyword.astroto usecrypto.randomUUID()instead ofMath.random()to generate thepopupIdto ensure better collision avoidance.@ -2,0 +2,4 @@import crypto from "node:crypto";import type { HTMLAttributes } from 'astro/types';type AriaRole = HTMLAttributes<'div'>['role'];@jules
Please implement this
@ -2,0 +2,4 @@import crypto from "node:crypto";import type { HTMLAttributes } from 'astro/types';type AriaRole = HTMLAttributes<'div'>['role'];I'm sorry, I'm a bit confused. I have already refactored this code to use
crypto.randomUUID()in the previous commit. Looking at the diff hunk you provided, it shows the original implementation withMath.random(). Did you review an older version of the PR, or is there something else you would like me to implement here?@ -2,0 +2,4 @@import crypto from "node:crypto";import type { HTMLAttributes } from 'astro/types';type AriaRole = HTMLAttributes<'div'>['role'];@jules
@ -2,0 +2,4 @@import crypto from "node:crypto";import type { HTMLAttributes } from 'astro/types';type AriaRole = HTMLAttributes<'div'>['role'];I have added the
role="term"attribute to the Keyword span as recommended. It should now be properly identified by screen readers./gemini review
Code Review
This pull request enhances the accessibility of the site by implementing ARIA roles and labels. Specifically, it adds
aria-labelledbyto major sections on the index page and introduces a tooltip mechanism for theKeywordcomponent usingaria-describedbyand unique IDs. Review feedback suggests replacingcrypto.randomUUID()to maintain compatibility with older Node.js versions and making therole="term"attribute configurable to avoid semantic inaccuracies in non-term contexts.@ -2,0 +2,4 @@import crypto from "node:crypto";import type { HTMLAttributes } from 'astro/types';type AriaRole = HTMLAttributes<'div'>['role'];The
role="term"attribute is now hardcoded for all instances of theKeywordcomponent. While this is appropriate for definitions (like pronunciation or skill descriptions), it is semantically incorrect when the component is used for simple labels or icons, such as the social links in the header. This can lead to confusing announcements for screen reader users (e.g., "GitHub, link, term"). Consider making theroleconfigurable via a prop, defaulting totermonly when the component truly represents a defined term.@ -11,3 +30,3 @@<span class="popup-anchor"><span class="popup"><span class="popup" id={popupId} role={hasRole ? "tooltip" : undefined}>(<slot />)The use of
crypto.randomUUID()will cause build failures in environments using Node.js versions earlier than 19 (such as Node 18, which is the current LTS and supported by Astro), as thecryptoobject is not available in the global scope by default in those versions. To ensure compatibility across all supported Node.js environments, consider using a more widely available method for generating unique IDs or explicitly importingrandomUUIDfromnode:crypto.@ -2,0 +2,4 @@import crypto from "node:crypto";import type { HTMLAttributes } from 'astro/types';type AriaRole = HTMLAttributes<'div'>['role'];@jules
Can you please implement this fix?
@ -2,0 +2,4 @@import crypto from "node:crypto";import type { HTMLAttributes } from 'astro/types';type AriaRole = HTMLAttributes<'div'>['role'];I have updated
Keyword.astroto accept aroleprop that defaults toterm. For usages where it's not semantically a term (like the social links), passingrole="none"will now omit the role attribute entirely./gemini review
Code Review
This pull request enhances the accessibility of the site by introducing ARIA roles and labels. The Keyword component now supports a role prop and uses crypto.randomUUID() to link tooltips with aria-describedby. Additionally, sections on the index page are now properly labeled using aria-labelledby. The review feedback suggests further accessibility refinements for the Keyword component when used in a presentational capacity (role='none'), specifically by defaulting tabindex to -1 and conditionally applying tooltip-related attributes to ensure a cleaner accessibility tree.
@ -1,15 +1,34 @@---When
roleis set to"none", the component is intended to be purely presentational. In such cases, it is better to defaulttabindexto"-1"so the element is not focusable by default. A focusable element without a semantic role can be confusing for screen reader users.To ensure a clean accessibility tree,
aria-describedbyand thetooltiprole should only be applied when the component is acting as a semantic term (i.e., whenroleis not"none"). This avoids creating orphaned descriptions or tooltips for presentational elements, which is especially important when the component is used inside other interactive elements like links.