Skip to content

Announce SegmentedControl selected state with aria-pressed#8196

Open
liuliu-dev wants to merge 2 commits into
mainfrom
liuliu/segmentedcontrol-aria-pressed
Open

Announce SegmentedControl selected state with aria-pressed#8196
liuliu-dev wants to merge 2 commits into
mainfrom
liuliu/segmentedcontrol-aria-pressed

Conversation

@liuliu-dev

@liuliu-dev liuliu-dev commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

related issue github/accessibility-audits#16804.

Note: needs https://github.com/github/github-ui/pull/27315 merged to pass integration tests

Changelog

Changed

SegmentedControl.Button and SegmentedControl.IconButton used aria-current to signal the selected segment. JAWS doesn't treat aria-current as a button state, so activating a segment produced no audible feedback, fails WCAG 4.1.2. Switching to aria-pressed (the toggle-button state) fixes the announcement. CSS selectors and tests are updated to match.

Rollout strategy

  • Patch release

Testing & Reviewing

@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 65a0b63

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

@liuliu-dev liuliu-dev added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Jul 20, 2026
@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 Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 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. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

@liuliu-dev
liuliu-dev marked this pull request as ready for review July 20, 2026 23:06
@liuliu-dev
liuliu-dev requested a review from a team as a code owner July 20, 2026 23:06
@liuliu-dev
liuliu-dev requested review from Copilot and joshblack July 20, 2026 23:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves SegmentedControl accessibility by switching the selected-state announcement from aria-current to aria-pressed, aligning the component’s semantics with screen reader expectations (notably JAWS) so activation produces audible feedback.

Changes:

  • Replace aria-current with aria-pressed on SegmentedControl.Button and SegmentedControl.IconButton.
  • Update CSS selectors and unit tests to target aria-pressed.
  • Add a changeset for a patch release documenting the accessibility improvement.
Show a summary per file
File Description
packages/react/src/SegmentedControl/SegmentedControlIconButton.tsx Use aria-pressed to expose icon-segment selected state to AT.
packages/react/src/SegmentedControl/SegmentedControlButton.tsx Use aria-pressed to expose text-segment selected state to AT.
packages/react/src/SegmentedControl/SegmentedControl.test.tsx Update assertions to validate aria-pressed state.
packages/react/src/SegmentedControl/SegmentedControl.module.css Update styling selectors to key off aria-pressed instead of aria-current.
.changeset/segmented-control-aria-pressed.md Patch changeset documenting the a11y behavior change.

Review details

  • Files reviewed: 5/5 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment thread packages/react/src/SegmentedControl/SegmentedControlButton.tsx
Comment thread packages/react/src/SegmentedControl/SegmentedControlIconButton.tsx
Comment thread packages/react/src/SegmentedControl/SegmentedControl.test.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR 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.

2 participants