Skip to content

fix(expandable components): Add/update aria attributes to expandable components #3054

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

Merged
merged 48 commits into from
Apr 24, 2025

Conversation

LinKCoding
Copy link
Contributor

@LinKCoding LinKCoding commented Mar 21, 2025

Overview

Components that expand other components should have an aria-expands attribute that denotes if an expandable component is expanded or not.

When using Voiceover, an element with an aria-expanded attribute, should announce if the element is "expanded" or "collapsed".
expanded example:
image
collapsed example:
image

This PR adds the aria-expanded attribute to Disclosure and InfoTip
It also updates guidance for Drawer + Flyout
Also updates ListRow to use ExpandControl.

Note: previously this PR also included aria-controls implementation, but that has moved to: #3069 and tabled for the time being

PR Checklist

  • Related to JIRA ticket: GM-1006
  • I have run this code to verify it works
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

  1. Check out Disclosure
  2. Inspect the component, see that the button now has an aria-expanded attribute
  3. turn on VO, toggle between expanding and collapsing and hear the correct state annouced
  4. Go to InfoTip
  5. repeat 2-3
  6. . Go to Drawer
  7. check that the guidance for aria-expanded is now updated
  8. Go to Flyout
  9. repeat step 7
  10. Check out List Expandable button
  11. Test that the expand/collapse feature works
  12. repeat steps above for Expandable Row
  13. ... take a deep breath ...
  14. Profit!

PR Links and Envs

Repository PR Link PR Env
Monolith Monolith PR Monolith Env
Portal Mono PR Portal Env
LE Mono PR LE Env
Brand Mono PR Brand Env

Copy link

nx-cloud bot commented Mar 21, 2025

View your CI Pipeline Execution ↗ for commit 8a23092.


☁️ Nx Cloud last updated this comment at 2025-04-24 16:06:32 UTC

Copy link

nx-cloud bot commented Mar 21, 2025

View your CI Pipeline Execution ↗ for commit c1991ca.

Command Status Duration Result
nx run-many --target=build --all ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-21 19:35:25 UTC

@LinKCoding LinKCoding requested a review from dreamwasp April 4, 2025 14:52
Copy link
Contributor

@dreamwasp dreamwasp left a comment

Choose a reason for hiding this comment

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

code here looks great - could you add the screenreader behavior we should expect when testing?

@@ -36,6 +37,7 @@ export const DisclosureButton: React.FC<DisclosureButtonProps> = ({
<FlexBox>
<DisclosureButtonWrapper
aria-expanded={isExpanded}
aria-controls={isExpanded ? ariaControlsId : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

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

should the id be on the button regardless of the expanded state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Woops, will update the testing instructions with the SR info, thanks!


re: id

tl;dr: an axe test was failing when, I think, aria-controls was trying to reference an id on an element that wasn't rendered yet. Adding this ternary solved the issue, but wondering if all these aria-controls should follow the pattern.

mini-story version: I didn't realize that Disclosure didn't have aria-expanded or aria-controls :\ so this is a new addition.

After I finished up with fixing some other failing mono tests, I saw that there was a failure on a Disclosure because of an "invalid value for aria-controls" https://github.com/codecademy-engineering/mono/actions/runs/14248719474/job/39936761982

Which I thought maybe that's cause I was using useId() and that values weren't readable to a person. So I swapped ALL of the useId instances with something more readable. And it was still failing lol (and I also had to fix a typo in the new id too x.x) So I read a bit more into it and saw this post: https://github.com/codecademy-engineering/mono/actions/runs/14248719474/job/39936761982 that mentioned that the element with the id should be on the page.

Then I updated Disclosure's aria-controls to this ternary and it fixed the issue. But I was hesitant about adding this logic to all the elements.

Copy link
Contributor

Choose a reason for hiding this comment

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

word, makes sense to me!

@LinKCoding LinKCoding requested a review from dreamwasp April 8, 2025 20:19
Copy link
Contributor

@aresnik11 aresnik11 left a comment

Choose a reason for hiding this comment

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

A couples questions and things I'm not seeing in storybook but mostly looking good!

  1. not seeing aria-controls on drawer/flyout when the component is collapsed
  2. should Disclosure have aria-controls? the PR desc says no but testing instructions says yes
  3. I don't see the id on the info tip, but possible i'm missing it or it needs to be added to the story

aresnik11 and others added 10 commits April 22, 2025 09:44
Adds bi-directional option for multiview modals, refactors the CTAs in multiview modals, and adds danger variant. Adds unit tests and additional stories.
Applying changes to the Modal and Dialog components per feedback from a11y team. 
Also adding a zIndex
@LinKCoding LinKCoding requested a review from aresnik11 April 23, 2025 20:42
Copy link
Contributor

@aresnik11 aresnik11 left a comment

Choose a reason for hiding this comment

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

One small note but otherwise LGTM!

Comment on lines +238 to +242
<ExpandControl
expanded={isExpanded}
onExpand={() => setExpanded(!isExpanded)}
disabled={false}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

this button used to have yellow text and now its grey. probably fine since this is just the storybook example but wanted to note

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ya, thanks Amy — I should've left a comment.
That seems intentional based on what the original component, I'll ask Stacey just in case :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gonna update to secondary to match the textButton styling :) thanks again~

@codecademydev
Copy link
Collaborator

📬Published Alpha Packages:

@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]

@codecademydev
Copy link
Collaborator

🚀 Styleguide deploy preview ready!

https://680a61aa84ab4600ba344771--gamut-preview.netlify.app

Deploy Logs

@LinKCoding LinKCoding added the Ship It :shipit: Automerge this PR when possible label Apr 24, 2025
@codecademydev codecademydev merged commit 71fd235 into main Apr 24, 2025
20 of 21 checks passed
@codecademydev codecademydev removed the Ship It :shipit: Automerge this PR when possible label Apr 24, 2025
@codecademydev codecademydev deleted the kl-gm-1006 branch April 24, 2025 16:52
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.

5 participants