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

SideNav - Conditionally set aria-labelledby #2788

Merged
merged 1 commit into from
Mar 27, 2025

Conversation

dchyun
Copy link
Contributor

@dchyun dchyun commented Mar 25, 2025

📌 Summary

If merged, this PR would set the aria-labelledby attribute in the SideNav toggle button, only if the @ariaLabel argument is not provided.

🛠️ Detailed description

Currently in the SideNav component's toggle button, there is a hardcoded aria-labelledby value of hds-side-nav-header present. The @ariaLabel argument sets the aria-label on the toggle button, but when this argument is set, the existing aria-labelledby is not removed. This leads to both aria-label and aria-labelledby being present on the toggle button. Since aria-labelledby overrides aria-label for screenreaders, the provided aria-label value is never announced.

To correct this behavior, the functionality has been changed so the hardcoded aria-labelledby is only set when the @ariaLabel argument is not used.

📸 Screenshots

Before

Screenshot 2025-03-25 at 12 55 43 PM

After

Screenshot 2025-03-25 at 12 54 37 PM

🔗 External links

Jira ticket: HDS-4549


👀 Component checklist

💬 Please consider using conventional comments when reviewing this PR.

Copy link

vercel bot commented Mar 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
hds-showcase ✅ Ready (Inspect) Visit Preview Mar 25, 2025 5:03pm
hds-website ✅ Ready (Inspect) Visit Preview Mar 25, 2025 5:03pm

@dchyun dchyun marked this pull request as ready for review March 25, 2025 17:24
@dchyun dchyun requested a review from a team as a code owner March 25, 2025 17:24
Copy link
Contributor

@MelSumner MelSumner left a comment

Choose a reason for hiding this comment

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

Please add documentation so that users understand what's happening and how to use this component correctly. Thank you!

@dchyun
Copy link
Contributor Author

dchyun commented Mar 25, 2025

Please add documentation so that users understand what's happening and how to use this component correctly. Thank you!

We have marked the @ariaLabel argument as deprecated. So, these changes I believe are only needed for teams that are still relying on that eventually deprecated argument. The docs already provide guidance on the preferred approach, using the SideNav::Header instead of @ariaLabel. I can add a note into the @ariaLabel component API anyway if we think that is needed.

@dchyun dchyun merged commit ebccb03 into main Mar 27, 2025
18 checks passed
@dchyun dchyun deleted the dchyun/side-nav-conditional-aria-labelledby branch March 27, 2025 13:15
@hashibot-hds hashibot-hds mentioned this pull request Mar 27, 2025
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.

4 participants