Repository navigation
fix: improve accordion accessibility - #5
michael-andreuzza merged 2 commits into
Conversation
|
@michael-andreuzza Hi Michael, this PR is my first contribution to your project! It adds accessible labels and descriptions to Accordion triggers while keeping existing usage unchanged. |
michael-andreuzza
left a comment
There was a problem hiding this comment.
Thanks João, this is a nice improvement and a great first contribution.
I checked out the branch and verified it end to end: astro check is clean, and in the browser's accessibility tree the triggers are now exposed as Account, Privacy, Security etc. with the description attached separately via aria-describedby, instead of the combined text. All the generated IDs resolve, no duplicates, plain triggers are untouched, toggling still works when clicking the new spans, and there's no visual change.
One small thing before I merge: the committed public/registry/accordion.json doesn't quite match the source. The Accordion.astro blob in there is a formatter-reformatted copy (double quotes) while the source file uses single quotes, so running npm run generate-registry on your branch modifies that file. Could you re-run the generator and commit the result so the branch is self-consistent?
The stepper.json changes are fine to keep. That's the generator catching up on drift from my last stepper commit, so it's actually a fix.
A few cosmetic nits inline. None of them are blockers.
| <span>Account</span> | ||
| <span class="text-sm text-muted-foreground font-normal"> | ||
| <AccordionLabel>Account</AccordionLabel> | ||
| <AccordionDescription class="text-sm text-muted-foreground font-normal"> |
There was a problem hiding this comment.
AccordionDescription already applies text-sm font-normal text-muted-foreground, so these classes are redundant in all the examples. Dropping them would show off the component defaults better.
| <span class="text-sm text-muted-foreground font-normal"> | ||
| <AccordionLabel>Account</AccordionLabel> | ||
| <AccordionDescription class="text-sm text-muted-foreground font-normal"> | ||
| Manage your account Settings01Icon |
There was a problem hiding this comment.
Pre-existing typo, not yours, but since you're touching these lines: this literally renders as "Manage your account Settings01Icon". Feel free to fix it to just "Manage your account settings".
| <span>Security</span> | ||
| <span class="text-sm text-muted-foreground font-normal"> | ||
| <AccordionLabel>Security</AccordionLabel> | ||
| <AccordionDescription class="text-sm text-muted-foreground font-normal"> |
There was a problem hiding this comment.
Double space before class.
Thanks Michael! (Sorry for the delayed response, it was a busy week) I’ve addressed the review feedback:
The changes are included in commit b9ff19d. |
|
Thanks João! Pulled the branch again and confirmed: |
What changed
Accordion triggers that include a title and supporting text were previously exposed as a single combined label.
For example, a trigger with “Privacy” and “Control your privacy preferences” could be announced as one long name. This makes navigation less concise and does not reflect the distinction shown visually between the title and its supporting text.
This PR adds optional
AccordionLabelandAccordionDescriptioncomponents. They connect the title and description to the trigger automatically, so assistive technologies can expose them separately.Existing accordions continue to work as before when these components are not used. The documentation and registry have also been updated.
How it was tested
npm run checknpm run build:allnpm run test:smoke