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

fix(LEMS-2225): add conditional aria-describedby logic #2283

Merged
merged 12 commits into from
Aug 1, 2024

Conversation

anakaren-rojas
Copy link
Contributor

@anakaren-rojas anakaren-rojas commented Jul 26, 2024

Summary:

Adds conditional logic to allow aria-describedby to be:

  • defined by the user (overrides default)
  • available in addition to aria-label or aria-labelledby

Issue: LEMS-2225

Test plan:

  1. yarn start in branch or chromatic link
  2. Navigate to Popover stories
  3. Choose With custom aria described by story
  4. Story includes hidden element that should be read out by the screen reader

Screenshots

Screen.Recording.2024-07-30.at.3.30.44.PM.mov

@anakaren-rojas anakaren-rojas self-assigned this Jul 26, 2024
Copy link

changeset-bot bot commented Jul 26, 2024

🦋 Changeset detected

Latest commit: c156d96

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-popover 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

@anakaren-rojas anakaren-rojas marked this pull request as draft July 26, 2024 18:39
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Jul 26, 2024

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/plenty-rockets-breathe.md, __docs__/wonder-blocks-popover/popover.stories.tsx, packages/wonder-blocks-popover/src/components/popover.tsx, packages/wonder-blocks-popover/src/components/__tests__/popover.test.tsx

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

@khan-actions-bot khan-actions-bot requested a review from a team July 26, 2024 18:39
Copy link
Contributor

github-actions bot commented Jul 26, 2024

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (2db7d76) 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="PR2283"

Packages can also be installed manually by running:

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

Copy link
Contributor

github-actions bot commented Jul 26, 2024

Size Change: +885 B (+0.94%)

Total Size: 95.3 kB

Filename Size Change
packages/wonder-blocks-form/dist/es/index.js 5.97 kB +871 B (+17.08%) ⚠️
packages/wonder-blocks-popover/dist/es/index.js 4.83 kB +8 B (+0.17%)
packages/wonder-blocks-tooltip/dist/es/index.js 6.79 kB +6 B (+0.09%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.78 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.57 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 887 B
packages/wonder-blocks-button/dist/es/index.js 4.03 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.06 kB
packages/wonder-blocks-core/dist/es/index.js 3.45 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-dropdown/dist/es/index.js 14.1 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.76 kB
packages/wonder-blocks-icon-button/dist/es/index.js 2.99 kB
packages/wonder-blocks-icon/dist/es/index.js 828 B
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.27 kB
packages/wonder-blocks-modal/dist/es/index.js 5.36 kB
packages/wonder-blocks-pill/dist/es/index.js 1.64 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.3 kB
packages/wonder-blocks-switch/dist/es/index.js 1.94 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.64 kB
packages/wonder-blocks-testing/dist/es/index.js 1.13 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-tokens/dist/es/index.js 1.74 kB
packages/wonder-blocks-toolbar/dist/es/index.js 855 B
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Jul 26, 2024

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

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

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.13%. Comparing base (68dd605) to head (fb9e0e0).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2283      +/-   ##
==========================================
+ Coverage   93.83%   95.13%   +1.30%     
==========================================
  Files         252      253       +1     
  Lines       29825    30240     +415     
  Branches     2440     1869     -571     
==========================================
+ Hits        27985    28770     +785     
+ Misses       1793     1463     -330     
+ Partials       47        7      -40     
Files Coverage Δ
...s/wonder-blocks-popover/src/components/popover.tsx 100.00% <100.00%> (ø)

... and 47 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 68dd605...fb9e0e0. Read the comment docs.

@anakaren-rojas anakaren-rojas changed the title adding aria described by changes fix(LEMS-2225): add conditional aria-describedby logic Jul 30, 2024
@anakaren-rojas anakaren-rojas marked this pull request as ready for review July 30, 2024 22:38
Copy link
Member

@catandthemachines catandthemachines left a comment

Choose a reason for hiding this comment

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

Just need to clean up one test file and a few comments and I think we're good to go! 🥳

.changeset/plenty-rockets-breathe.md Outdated Show resolved Hide resolved
@@ -87,6 +87,16 @@ const styles = StyleSheet.create({
flexDirection: "row",
gap: spacing.medium_16,
},
srOnly: {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Does WonderBlocks have a utility constant for this? It would be great if it was in a shared file for other WonderBlocks components to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't seem like it; I'd imagine since wonderblocks hosts components, they would all need to be visible

@handeyeco handeyeco requested a review from jandrade August 1, 2024 20:07
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 great to me! Just left a minor suggestion on refactoring one of the tests, but nothing blocking. Thanks for working on this improvement :shipit:

Comment on lines 623 to 624
await screen.findByRole("dialog", {
description: "This is a popover description",
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: With this refactor in place, I think it makes sense to create a separate test to assert the description part of this test.

For some context, we try to follow the AAA approach for testing: https://khanacademy.atlassian.net/wiki/spaces/ENG/pages/98402353/JavaScript+Testing+Best+Practices#Assert-One-Requirement-Per-Test
https://khanacademy.atlassian.net/wiki/spaces/ENG/pages/98402353/JavaScript+Testing+Best+Practices#Assert-One-Requirement-Per-Test

One of the main benefits we have found by using this approach is that it's easier to isolate a failure when it happens and also easier to apply the fix when needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Juan, I split it out into three tests that each have 1 assertion

@anakaren-rojas anakaren-rojas merged commit 166ae1d into main Aug 1, 2024
15 checks passed
@anakaren-rojas anakaren-rojas deleted the add-aria-described-by branch August 1, 2024 22:05
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.

4 participants