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

Make Accordion fully accessible #2113

Merged
merged 3 commits into from
Nov 16, 2023
Merged

Make Accordion fully accessible #2113

merged 3 commits into from
Nov 16, 2023

Conversation

nishasy
Copy link
Contributor

@nishasy nishasy commented Nov 15, 2023

Summary:

This PR includes

  • a11y mdx docs
  • the addition of region as advised by w3
  • the addition of aria-labelledby as advised by w3
  • tests

Issue: https://khanacademy.atlassian.net/browse/WB-1585

Test plan:

yarn jest packages/wonder-blocks-accordion/src/components/__tests__/accordion.test.tsx

Go to the storybook page and check the accessibility tool to confirm
that region and aria-labelledby are set appropriately.

Turn on Voiceover and confirm that the new region(s) are available in the landmarks menu.

trimmed.mov

@nishasy nishasy self-assigned this Nov 15, 2023
Copy link

changeset-bot bot commented Nov 15, 2023

🦋 Changeset detected

Latest commit: 8f11dae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/wonder-blocks-accordion Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Merging #2113 (8f11dae) into main (7b24db9) will increase coverage by 0.00%.
Report is 5 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2113   +/-   ##
=======================================
  Coverage   97.06%   97.07%           
=======================================
  Files         243      243           
  Lines       28203    28238   +35     
  Branches     2462     2382   -80     
=======================================
+ Hits        27376    27411   +35     
  Misses        827      827           
Files Coverage Δ
...ordion/src/components/accordion-section-header.tsx 100.00% <100.00%> (ø)
...cks-accordion/src/components/accordion-section.tsx 100.00% <100.00%> (ø)
...nder-blocks-accordion/src/components/accordion.tsx 100.00% <100.00%> (ø)

... and 11 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b24db9...8f11dae. Read the comment docs.

Copy link
Contributor

github-actions bot commented Nov 15, 2023

Size Change: +12 B (0%)

Total Size: 92.7 kB

Filename Size Change
packages/wonder-blocks-accordion/dist/es/index.js 3.66 kB +132 B (+4%)
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.72 kB +28 B (+2%)
packages/wonder-blocks-button/dist/es/index.js 4.26 kB -63 B (-1%)
packages/wonder-blocks-dropdown/dist/es/index.js 12 kB -36 B (0%)
packages/wonder-blocks-form/dist/es/index.js 5.34 kB -74 B (-1%)
packages/wonder-blocks-search-field/dist/es/index.js 1.55 kB +25 B (+2%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 1.13 kB
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.23 kB
packages/wonder-blocks-color/dist/es/index.js 1.15 kB
packages/wonder-blocks-core/dist/es/index.js 3.67 kB
packages/wonder-blocks-data/dist/es/index.js 6.33 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.54 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3.06 kB
packages/wonder-blocks-icon/dist/es/index.js 3.04 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.88 kB
packages/wonder-blocks-link/dist/es/index.js 2.54 kB
packages/wonder-blocks-modal/dist/es/index.js 5.04 kB
packages/wonder-blocks-pill/dist/es/index.js 1.03 kB
packages/wonder-blocks-popover/dist/es/index.js 4.33 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.51 kB
packages/wonder-blocks-spacing/dist/es/index.js 158 B
packages/wonder-blocks-switch/dist/es/index.js 2.06 kB
packages/wonder-blocks-testing/dist/es/index.js 3.94 kB
packages/wonder-blocks-theming/dist/es/index.js 1.21 kB
packages/wonder-blocks-timing/dist/es/index.js 1.78 kB
packages/wonder-blocks-toolbar/dist/es/index.js 862 B
packages/wonder-blocks-tooltip/dist/es/index.js 5.05 kB
packages/wonder-blocks-typography/dist/es/index.js 1.49 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Nov 15, 2023

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-wnweeyosuo.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 321
Tests with visual changes 1
Total stories 393
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 321

@nishasy nishasy requested review from jandrade and a team November 15, 2023 05:54
@nishasy nishasy marked this pull request as ready for review November 15, 2023 05:54
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/smart-flowers-wave.md, __docs__/wonder-blocks-accordion/accessibility.stories.mdx, packages/wonder-blocks-accordion/src/components/accordion-section-header.tsx, packages/wonder-blocks-accordion/src/components/accordion-section.tsx, packages/wonder-blocks-accordion/src/components/accordion.tsx, packages/wonder-blocks-accordion/src/components/__tests__/accordion-section-header.test.tsx, packages/wonder-blocks-accordion/src/components/__tests__/accordion.test.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor

github-actions bot commented Nov 15, 2023

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (6bbc4d6) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2113"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2113

@nishasy nishasy requested a review from a team November 15, 2023 17:43
Copy link
Member

@jandrade jandrade left a comment

Choose a reason for hiding this comment

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

Looks amazing! Thanks for the super detailed docs + tests 🚀

Copy link
Member

Choose a reason for hiding this comment

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

praise: This is sooo well detailed 👏

Comment on lines +60 to +62
- The accordion can be animated using the `animated` prop. However,
PLEASE set this according to the users' "prefers reduced motion"
setting (this can be in the application or in their operating system).
Copy link
Member

Choose a reason for hiding this comment

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

praise: Thanks for specifying this here!

Comment on lines 495 to 497
// Not testing the actual value of the aria-labelledby attribute
// because it comes from the unique ID generator.
expect(section1ContentPanel).toHaveAttribute("aria-labelledby");
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: I think you can still check the aria-labelledby value if you pass an id to the AccordionSection instance.

e.g.

<AccordionSection id="test"...>

then the panel would probably have something like: aria-labeledby=test-accordion-section-header

Copy link
Contributor Author

@nishasy nishasy Nov 15, 2023

Choose a reason for hiding this comment

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

Oh right! Thank you. I do think I have to update the headerId to make sure it uses a passed in ID to get that to work because I think it's only using a unique ID right now.

@@ -75,6 +75,8 @@ type Props = AriaProps & {
style?: StyleType;
};

const LANDMARK_PROLIFERATION_THRESHOLD = 6;
Copy link
Member

Choose a reason for hiding this comment

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

praise: Thanks for adding this check 💯.

@nishasy nishasy merged commit 16d99bd into main Nov 16, 2023
13 checks passed
@nishasy nishasy deleted the accordion-a11y branch November 16, 2023 01:08
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.

3 participants