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 4 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: d7becde 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 |
|
👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/14468 |
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