Skip to content

fix(segmented-buttons): use radio and checkbox roles for aria-checked - #5186

Open
EnesKartal wants to merge 2 commits into
callstack:mainfrom
EnesKartal:fix/segmented-buttons-aria-checked
Open

EnesKartal wants to merge 2 commits into
callstack:mainfrom
EnesKartal:fix/segmented-buttons-aria-checked

Conversation

@EnesKartal

@EnesKartal EnesKartal commented Nov 6, 2026 •

Copy link
Copy Markdown

Motivation

On web, each SegmentedButtons segment sets aria-checked on role="button", which ARIA disallows (axe aria-allowed-attr), so the checked state isn't announced.

Related issue

Fixes #5181

Screenshots / Videos

No visual change, only roles: single select → radio segments in a radiogroup row; multiSelect → checkbox segments.

Test plan

  • New RNTL tests for roles + checked state; snapshot diff is only role values.
  • SegmentedButton jest suite, yarn typecheck, yarn lint pass.
  • Manual: example app on web → /segmented-button → axe shows no aria-allowed-attr (not run by me).

Same pattern as ConnectedButtonGroup (#5074).

Prepared with AI assistance; I reviewed and tested the change.

Each segment set aria-checked on role=button, which is not allowed by ARIA. Single select segments now use role=radio inside a radiogroup, and multiSelect segments use role=checkbox.

Fixes callstack#5181
Copilot AI balanced review requested due to automatic review settings November 6, 2026 18:35
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Found potential problems with the pull request:

  • Screenshot or video evidence is missing. Make sure to include one if it affects the UI.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Doberjohn Doberjohn added this to the 6.0.0 milestone Nov 9, 2026
@omerfarukgurbuz

Copy link
Copy Markdown

The new radiogroup needs a group-level accessible name API. At 2becd83, the wrapper only receives role and style, and Props does not expose a group label. The individual segment labels do not name their group.

WAI-ARIA 1.2 requires an author-provided accessible name for radiogroup. Rendering this PR's actual components with React 19.3.0 and React Native Web 0.21.4 confirms that even passing aria-label="Transport" results in an unnamed group: the prop is discarded.

Please expose and forward aria-label and aria-labelledby to the single-select wrapper, add a labelled usage example, and cover both naming paths. Keep those attributes off the current generic multi-select wrapper. I checked a small patch with DOM tests: the named-group assertion fails on this PR and passes with the forwarding change; checkbox selection and the existing multi-select wrapper remain unchanged. This validation used jsdom with Reanimated animations stubbed and the visual ripple disabled; no screen-reader or device testing was performed.

@EnesKartal

Copy link
Copy Markdown
Author

Thanks for checking this so carefully. SegmentedButtons now accepts aria-label and aria-labelledby and forwards them only to the single-select radiogroup wrapper; the multi-select wrapper stays unchanged. The docs usage and the default example now pass aria-label="Transport mode", and there are tests for both naming paths plus one making sure the multi-select wrapper does not get them.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 20:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SegmentedButtons: each segment sets aria-checked on role button

4 participants