Skip to content

Comments

SegmentedControl: include counter in button accessible name when aria-label is provided#7587

Open
liuliu-dev wants to merge 4 commits intomainfrom
liuliu/fix-segmentedcontrol-a11y
Open

SegmentedControl: include counter in button accessible name when aria-label is provided#7587
liuliu-dev wants to merge 4 commits intomainfrom
liuliu/fix-segmentedcontrol-a11y

Conversation

@liuliu-dev
Copy link
Contributor

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

  • 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

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2026

🦋 Changeset detected

Latest commit: d7becde

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

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Feb 24, 2026
@github-actions
Copy link
Contributor

👋 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 integration-tests: skipped manually label to skip these checks.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

@primer-integration
Copy link

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/14468

@primer-integration
Copy link

Integration test results from github/github-ui:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant