Skip to content

fix: improve accordion accessibility - #5

Merged
michael-andreuzza merged 2 commits into
michael-andreuzza:mainfrom
JoaoTMDias:feat/accordion-improvements
Sep 20, 2026
Merged

michael-andreuzza merged 2 commits into
michael-andreuzza:mainfrom
JoaoTMDias:feat/accordion-improvements

Conversation

@JoaoTMDias

@JoaoTMDias JoaoTMDias commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

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 AccordionLabel and AccordionDescription components. 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 check
  • npm run build:all
  • npm run test:smoke
  • Tested adding the Accordion through the local CLI registry

@JoaoTMDias

Copy link
Copy Markdown
Contributor Author

@michael-andreuzza Hi Michael, this PR is my first contribution to your project!
It is ready for review when you have a chance.

It adds accessible labels and descriptions to Accordion triggers while keeping existing usage unchanged.
Thanks!

@michael-andreuzza michael-andreuzza left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

Comment thread src/content/components/accordion.mdx Outdated
<span>Account</span>
<span class="text-sm text-muted-foreground font-normal">
<AccordionLabel>Account</AccordionLabel>
<AccordionDescription class="text-sm text-muted-foreground font-normal">

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

Comment thread src/content/components/accordion.mdx Outdated
<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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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".

Comment thread src/content/components/accordion.mdx Outdated
<span>Security</span>
<span class="text-sm text-muted-foreground font-normal">
<AccordionLabel>Security</AccordionLabel>
<AccordionDescription class="text-sm text-muted-foreground font-normal">

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Double space before class.

@JoaoTMDias

Copy link
Copy Markdown
Contributor Author

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.

Thanks Michael! (Sorry for the delayed response, it was a busy week)

I’ve addressed the review feedback:

  • Re-ran the registry generator so public/registry/accordion.json now matches the source formatting.
  • Removed the redundant classes from AccordionDescription.
  • Fixed the existing Settings01Icon typo in the example text.
  • Cleaned up the extra space before class.

The changes are included in commit b9ff19d.
Thanks again for the review!

@michael-andreuzza

Copy link
Copy Markdown
Owner

Thanks João! Pulled the branch again and confirmed: npm run generate-registry is now a no-op on your branch, astro check is clean, and all the nits are addressed (nice catch on the second Settings01Icon typo in the cards example too). Merging now. Great first contribution, appreciate it.

@michael-andreuzza
michael-andreuzza merged commit cf84f7b into michael-andreuzza:main Sep 20, 2026
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