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 missing selection attributes in ActionList items #4096

Merged
merged 8 commits into from
Dec 21, 2023

Conversation

strackoverflow
Copy link
Member

@strackoverflow strackoverflow commented Dec 20, 2023

Addresses the following a11y audit issue: https://github.com/github/accessibility-audits/issues/4484 (GitHub staff only)

This PR fixes an accessibility issue with ActionList items not reporting their selection state to screen readers.

The aria-selected (or aria-checked) attributes were not being applied to ActionList.Item because they were only being read from ActionListContainerContext, but ActionList instances don't provide that context.

The solution I chose here was to automatically infer the selection attribute type based on the item's role: menuitemcheckbox and menuitemradio roles get an inferred selection attribute of aria-checked, while option roles will get aria-selected.

Of course, if a selection attribute is specified through ActionListContainerContext, that will be preferred.

Interestingly, selection state was asserted in one of the component tests, but the aria-selected attribute was manually provided in the test stub. Removing that allows the test to assert the actual selection behavior.

Demo

This screenshot demonstrates the NVDA screenreader properly announcing the selection state with this change:

screenshot of NVDA properly announcing selection state

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@strackoverflow strackoverflow self-assigned this Dec 20, 2023
Copy link

changeset-bot bot commented Dec 20, 2023

🦋 Changeset detected

Latest commit: dc1ea48

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

This PR includes changesets to release 1 package
Name Type
@primer/react 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
Contributor

github-actions bot commented Dec 20, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 104.94 KB (+0.07% 🔺)
dist/browser.umd.js 105.51 KB (+0.07% 🔺)

@@ -789,6 +789,7 @@ exports[`snapshots renders a menu that contains an item to add to the menu 1`] =
>
<li
aria-labelledby="0--label "
aria-selected={false}
Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like Autocomplete might have had a similar issue with list items not having aria-selected attributes, and this fix applies here as well.

@strackoverflow strackoverflow marked this pull request as ready for review December 21, 2023 17:36
@strackoverflow strackoverflow requested review from a team and joshblack December 21, 2023 17:36
@strackoverflow strackoverflow added this pull request to the merge queue Dec 21, 2023
Merged via the queue into main with commit 1b9011d Dec 21, 2023
30 checks passed
@strackoverflow strackoverflow deleted the action-list-selected branch December 21, 2023 20:37
@primer primer bot mentioned this pull request Dec 21, 2023
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.

2 participants