-
Notifications
You must be signed in to change notification settings - Fork 592
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
Conversation
🦋 Changeset detectedLatest commit: dc1ea48 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
size-limit report 📦
|
@@ -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} |
There was a problem hiding this comment.
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.
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
(oraria-checked
) attributes were not being applied toActionList.Item
because they were only being read fromActionListContainerContext
, butActionList
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
andmenuitemradio
roles get an inferred selection attribute ofaria-checked
, whileoption
roles will getaria-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:
Rollout strategy
Testing & Reviewing
Merge checklist