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

WB-1636: Announce popover contents correctly to screen readers #2134

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

jandrade
Copy link
Member

@jandrade jandrade commented Dec 4, 2023

Summary:

The Popover dialog element is not assigning correctly the aria-describedby
value, thus causing Screen Readers not being able to read the popover contents
correctly.

This PR fixes the issue by assigning the aria-describedby value to the popover
content, and also associates the popover title with the popover dialog via the
aria-labelledby attribute. By implementing this, the popover dialog will be
read correctly by Screen Readers.

Also fixed some issues with the Storybook docs by adding correct descriptions
and fixing some of the Arg types to the Popover component.

Issue: WB-1636

Test plan:

This is better to be tested with Safari + VoiceOver.

  1. Open any popover story in Storybook and click on the popover trigger.
  2. Verify that the popover dialog is read correctly by VoiceOver. The popover
    title should be read as soon as the popover dialog is opened.

BEFORE
popover-sr-before

AFTER
popover-sr-after

@jandrade jandrade self-assigned this Dec 4, 2023
Copy link

changeset-bot bot commented Dec 4, 2023

🦋 Changeset detected

Latest commit: d17c268

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

@khan-actions-bot khan-actions-bot requested a review from a team December 4, 2023 20:02
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/dirty-dingos-battle.md, __docs__/wonder-blocks-popover/popover-content-core.stories.tsx, __docs__/wonder-blocks-popover/popover-content.stories.tsx, __docs__/wonder-blocks-popover/popover.accessibility.stories.mdx, __docs__/wonder-blocks-popover/popover.argtypes.tsx, __docs__/wonder-blocks-popover/popover.stories.tsx, packages/wonder-blocks-popover/src/components/popover-content-core.tsx, packages/wonder-blocks-popover/src/components/popover-content.tsx, packages/wonder-blocks-popover/src/components/popover-dialog.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.

Copy link
Contributor

github-actions bot commented Dec 4, 2023

Size Change: +44 B (0%)

Total Size: 91 kB

Filename Size Change
packages/wonder-blocks-popover/dist/es/index.js 4.38 kB +44 B (+1%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.69 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.72 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 1.13 kB
packages/wonder-blocks-button/dist/es/index.js 4.27 kB
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.24 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-dropdown/dist/es/index.js 12 kB
packages/wonder-blocks-form/dist/es/index.js 5.34 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.21 kB
packages/wonder-blocks-icon/dist/es/index.js 1.06 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-progress-spinner/dist/es/index.js 1.51 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.55 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 Dec 4, 2023

npm Snapshot: Published

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

Packages can also be installed manually by running:

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

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Merging #2134 (d17c268) into main (9092363) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2134   +/-   ##
=======================================
  Coverage   97.05%   97.05%           
=======================================
  Files         241      241           
  Lines       28038    28055   +17     
  Branches     2464     2417   -47     
=======================================
+ Hits        27212    27229   +17     
  Misses        826      826           
Files Coverage Δ
...ks-popover/src/components/popover-content-core.tsx 100.00% <100.00%> (ø)
...-blocks-popover/src/components/popover-content.tsx 99.37% <100.00%> (+0.02%) ⬆️
...r-blocks-popover/src/components/popover-dialog.tsx 99.32% <100.00%> (+<0.01%) ⬆️
...s/wonder-blocks-popover/src/components/popover.tsx 100.00% <100.00%> (ø)

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 9092363...d17c268. Read the comment docs.

Copy link
Contributor

github-actions bot commented Dec 4, 2023

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

Metric Total
Captured snapshots 7
Tests with visual changes 3
Total stories 389
Inherited (not captured) snapshots [TurboSnap] 309
Tests on the build 316

</View>
</>
),
closeButtonVisible: true,
style: styles.popoverWithIcon,
},
render: (args) => <PopoverContentCore {...args} />,
Copy link
Member Author

Choose a reason for hiding this comment

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

note: These render wrappers are included to solve a known SB issue with reusable stories + CSF 3 (I added a comment in another part to point to this ticket): See storybookjs/storybook#15954 (comment)

@@ -106,8 +108,9 @@ export const WithIcon: StoryComponentType = {
args: {
title: "Popover with Icon",
content: "Popovers can include images on the left.",
icon: <img src="/logo.svg" width="100%" alt="Wonder Blocks logo" />,
icon: <img src="./logo.svg" width="100%" alt="Wonder Blocks logo" />,
Copy link
Member Author

Choose a reason for hiding this comment

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

note: Adding relative paths to fix some issues in the production version of SB (these images are broken in there).

};

export default {
children: {
description:
Copy link
Member Author

Choose a reason for hiding this comment

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

note: Added descriptions to improve the Popover documentation in SB.

* these attributes. Also, make sure to assign the `${id}-title` prop to the
* `title` element and `${id}-content` prop to the `content` element.
*/
export const CustomPopoverContent: StoryComponentType = {
Copy link
Member Author

Choose a reason for hiding this comment

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

note: I noticed that we didn't include a story with custom popovers, so I added it here. This also helps to manually test custom popovers with screen readers.

Copy link
Member

@jeresig jeresig left a comment

Choose a reason for hiding this comment

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

Oh, fantastic! Thanks for resolving this.

@jandrade jandrade merged commit 66f233d into main Dec 5, 2023
22 of 24 checks passed
@jandrade jandrade deleted the popover-wb-1636 branch December 5, 2023 18:56
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