Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accordion: make toggle button names unique #2383

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

shleewhite
Copy link
Contributor

@shleewhite shleewhite commented Sep 3, 2024

๐Ÿ“Œ Summary

If merged, this PR would update the accordion toggle to make the button names unique.

๐Ÿ› ๏ธ Detailed description

To make aria-label not required on each item but still create unique labels for the toggle buttons, I decided to use aria-labelledby. aria-labelledby is set to the id of the wrapper around the toggle block and I removed the aria-label default value. This makes it so the accessible name is just the title of the accordion.

If the developer passes an aria-label to the accordion item, aria-labelledby isn't set.

NOTE:

I used to have a different implementation where I also included a visually hidden piece of text that said "Expand" so the button name would be "Expand {title}", but after discussing with @MelSumner we decided that wasn't even necessary because the fact that it shows/hide content is implied by aria-expanded. When you navigate to the button with VoiceOver it says "{title}, collapsed, button" and then when you press the button it says "expanded". this makes including the word "expand" in the button name redundnant.

๐Ÿ“ธ Screenshots

DOM after changes:

๐Ÿ”— External links

Jira ticket: HDS-3809


๐Ÿ‘€ Component checklist

๐Ÿ’ฌ Please consider using conventional comments when reviewing this PR.

Copy link

vercel bot commented Sep 3, 2024

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Updated (UTC)
hds-showcase โœ… Ready (Inspect) Visit Preview Sep 4, 2024 6:59pm
hds-website โœ… Ready (Inspect) Visit Preview Sep 4, 2024 6:59pm

@shleewhite shleewhite changed the title feat: make accordion item toggle buttons more unique Accordion: make toggle button names unique Sep 3, 2024
@shleewhite shleewhite changed the title Accordion: make toggle button names unique Accordion: make toggle button names unique Sep 3, 2024
@shleewhite shleewhite requested review from a team and MelSumner September 3, 2024 19:16
@shleewhite shleewhite marked this pull request as ready for review September 3, 2024 19:16
Copy link
Contributor

@zamoore zamoore left a comment

Choose a reason for hiding this comment

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

Cool change!

What do you think about adding an integration test to make sure the property value is set correctly?

@shleewhite shleewhite force-pushed the hds-3809/unique-accordion-item-label branch from 4b232e6 to 932b5d4 Compare September 4, 2024 15:13
@shleewhite
Copy link
Contributor Author

Cool change!

What do you think about adding an integration test to make sure the property value is set correctly?

@zamoore for sure! just added a couple tests.

Copy link
Contributor

@KristinLBradley KristinLBradley left a comment

Choose a reason for hiding this comment

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

Looks good!

@shleewhite shleewhite merged commit 49cc9d3 into main Sep 6, 2024
16 checks passed
@shleewhite shleewhite deleted the hds-3809/unique-accordion-item-label branch September 6, 2024 17:16
@hashibot-hds hashibot-hds mentioned this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants