SegmentedControl: include counter in button accessible name when aria-label is provided#7587
SegmentedControl: include counter in button accessible name when aria-label is provided#7587liuliu-dev wants to merge 5 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 11a6918 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 |
|
👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the |
There was a problem hiding this comment.
Pull request overview
This pull request fixes an accessibility issue in SegmentedControl where screen readers weren't announcing the count value when a custom aria-label was provided on a button. When an aria-label is set on a button element, it overrides the button's text content, which previously caused the counter value to be excluded from the accessible name even though it was visually displayed.
Changes:
- Modified SegmentedControl.Button to concatenate the count value with the aria-label when both are provided
- Added test coverage for the new behavior
- Added a changeset documenting this as a patch release
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/react/src/SegmentedControl/SegmentedControlButton.tsx | Extracts aria-label from props, computes a combined aria-label with count when both exist, and applies it to the button element |
| packages/react/src/SegmentedControl/SegmentedControl.test.tsx | Adds test to verify the count is included in the accessible name when aria-label is provided |
| .changeset/evil-islands-find.md | Documents the fix as a patch release for accessibility improvement |
.changeset/evil-islands-find.md
Outdated
| '@primer/react': patch | ||
| --- | ||
|
|
||
| Fixes an accessibility issue where screen readers announce segmented control buttons without their associated count. |
There was a problem hiding this comment.
nit/petty:
| Fixes an accessibility issue where screen readers announce segmented control buttons without their associated count. | |
| SegmentedControl: Screen readers now announce buttons with their associated count. Fixes [accessibility-audits#14898](https://github.com/github/accessibility-audits/issues/14898) |
this makes the changelog easier to parse quickly.
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/14673 |
|
Integration test results from github/github-ui:
CI check runs linting, type checking, and unit tests. Check the workflow logs for specific failures. Need help? If you believe this failure is unrelated to your changes, please reach out to the Primer team for assistance. |
|
Closing this PR since this appears to be a Storybook only issue. Addressed in #7603 |
Related issue: https://github.com/github/accessibility-audits/issues/14898
Changelog
Fixes an accessibility issue where screen readers announce segmented control buttons without their associated count.
Rollout strategy
Testing & Reviewing
Merge checklist