Skip to content

Conversation

@rkishan516
Copy link
Contributor

feat: apply radioGroup role to segmented control widgets
fixes: #164589

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Sep 28, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request applies the radioGroup semantics role to CupertinoSegmentedControl and CupertinoSlidingSegmentedControl to improve accessibility. The implementation wraps the widgets in a Semantics widget. My review suggests adding container: true to these Semantics widgets to ensure they create distinct semantics nodes, preventing potential issues with merging semantics in complex widget trees. The rest of the changes, including test updates, look correct.

padding: widget.padding ?? _kHorizontalItemPadding,
child: UnconstrainedBox(constrainedAxis: Axis.horizontal, child: box),
return Semantics(
role: SemanticsRole.radioGroup,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To ensure this Semantics widget creates a distinct node in the semantics tree for the radioGroup, it's important to make it a container by setting container: true. This prevents the radioGroup role from merging with an ancestor Semantics widget, which could lead to an incorrect semantics tree structure. Making this a container ensures it acts as a boundary and correctly groups the child segment nodes.

      container: true,
      role: SemanticsRole.radioGroup,

Copy link
Contributor

Choose a reason for hiding this comment

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

This is how it is used in RadioGroup as well.

);
},
return Semantics(
role: SemanticsRole.radioGroup,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To ensure this Semantics widget creates a distinct node in the semantics tree for the radioGroup, it's important to make it a container by setting container: true. This prevents the radioGroup role from merging with an ancestor Semantics widget, which could lead to an incorrect semantics tree structure. Making this a container ensures it acts as a boundary and correctly groups the child segment nodes.

      container: true,
      role: SemanticsRole.radioGroup,

Copy link
Contributor

Choose a reason for hiding this comment

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

And here too.

@rkishan516 rkishan516 force-pushed the a11y-segmented-control branch 3 times, most recently from 1a26f4d to 870ed41 Compare September 30, 2025 02:07
@victorsanni
Copy link
Contributor

victorsanni commented Sep 30, 2025

LGTM, awaiting review from more accessibility experts.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

Radio Group has certain keyboard navigation. should the keyboard navigation applies to segmented button? https://www.w3.org/WAI/ARIA/apg/patterns/radio/

@rkishan516 rkishan516 force-pushed the a11y-segmented-control branch 2 times, most recently from 956b217 to 4820b4c Compare October 1, 2025 02:21
@rkishan516
Copy link
Contributor Author

Radio Group has certain keyboard navigation. should the keyboard navigation applies to segmented button? https://www.w3.org/WAI/ARIA/apg/patterns/radio/

Hey @chunhtai, I have added keyboard navigation to segmented controls.

@rkishan516 rkishan516 requested a review from chunhtai October 1, 2025 02:24
@rkishan516 rkishan516 force-pushed the a11y-segmented-control branch 2 times, most recently from 52236d2 to c6e8ec9 Compare October 1, 2025 02:58
@chunhtai
Copy link
Contributor

chunhtai commented Oct 1, 2025

Hi @rkishan516 , sorry I should have mentioned this. I think we can reuse RadioGroup to implement the groupvalue/value change logic in CupertinoSegmentedController, this way, we get all these for free. including keyboard behavior and semantics.

To do that, just wrap all buttons with a RadioGroup and each button either uses RawRadio, or implement RadioClient if the API is not compatible with RawRadio.

@rkishan516
Copy link
Contributor Author

I think we can reuse RadioGroup to implement the groupvalue/value change logic in CupertinoSegmentedController, this way, we get all these for free. including keyboard behavior and semantics.

To do that, just wrap all buttons with a RadioGroup and each button either uses RawRadio, or implement RadioClient if the API is not compatible with RawRadio.

Hey, Sorry. I should have thought about it. Let me update the implementation using RadioGroup widget.

@rkishan516 rkishan516 force-pushed the a11y-segmented-control branch from c6e8ec9 to 316d410 Compare October 1, 2025 16:42
@victorsanni victorsanni self-requested a review October 6, 2025 19:02
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 10, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 10, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 10, 2025

autosubmit label was removed for flutter/flutter/176157, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

@rkishan516 rkishan516 added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 10, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 10, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 10, 2025

autosubmit label was removed for flutter/flutter/176157, because - The status or check suite Mac_x64 framework_tests_misc has failed. Please fix the issues identified (or deflake) before re-applying this label.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 15, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 15, 2025
Manual roll Flutter from e11e2c1 to 7cd821c (73 revisions)

Manual roll requested by tarrinneal@google.com

flutter/flutter@e11e2c1...7cd821c

2025-10-14 bruno.leroux@gmail.com Fix computeDistanceToActualBaseline throws when accessing child size (flutter/flutter#176906)
2025-10-14 47866232+chunhtai@users.noreply.github.com iOS can set application locale before view controller is set (flutter/flutter#176592)
2025-10-14 jason-simmons@users.noreply.github.com Roll ANGLE to a branch based on d9fa255a5c22 (flutter/flutter#176747)
2025-10-14 47866232+chunhtai@users.noreply.github.com Relands "Fixes keyboard selects disabled radio" (flutter/flutter#176977)
2025-10-14 huy@nevercode.io Fix expansion tile is missing state announcement on non-Apple platforms (flutter/flutter#175480)
2025-10-14 30870216+gaaclarke@users.noreply.github.com impeller: allows access of float uniforms by name (flutter/flutter#176728)
2025-10-14 aam@google.com Roll dart sdk to 3.11.0-17.0.dev (flutter/flutter#176947)
2025-10-13 okorohelijah@google.com Move iOS integration tests (flutter/flutter#176940)
2025-10-13 ahmedsameha1@gmail.com Make sure that an InputDatePickerFormField doesn't crash in 0x0 envir… (flutter/flutter#176047)
2025-10-13 jason-simmons@users.noreply.github.com [web] Match the behavior of other platforms in Web Locale.toString if the country code is an empty string (flutter/flutter#176862)
2025-10-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Fixes keyboard selects disabled radio (#176727)" (flutter/flutter#176958)
2025-10-13 47866232+chunhtai@users.noreply.github.com Fixes keyboard selects disabled radio (flutter/flutter#176727)
2025-10-13 engine-flutter-autoroll@skia.org Roll Packages from e319c40 to d062181 (2 revisions) (flutter/flutter#176916)
2025-10-13 jason-simmons@users.noreply.github.com Roll SwiftShader to 794b0cfce1d8 (flutter/flutter#176806)
2025-10-13 32538273+ValentinVignal@users.noreply.github.com Make DropdownMenu generic type non nullable (flutter/flutter#176711)
2025-10-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from BWGpRvpdQh-HJpq1c... to _dd0Jv50H0oUI2Ad8... (flutter/flutter#176895)
2025-10-11 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from JpiUsek1hU5r9QVKP... to BWGpRvpdQh-HJpq1c... (flutter/flutter#176880)
2025-10-11 codefu@google.com fix: content hash check for LUCI_CONTEXT (flutter/flutter#176867)
2025-10-11 34465683+rkishan516@users.noreply.github.com Feat: make tooltip position customizeable (flutter/flutter#175047)
2025-10-11 engine-flutter-autoroll@skia.org Roll Dart SDK from d88d8bf2b53c to 65b171958c93 (3 revisions) (flutter/flutter#176871)
2025-10-11 34465683+rkishan516@users.noreply.github.com feat: apply radioGroup role to segmented control widgets (flutter/flutter#176157)
2025-10-10 ahmedsameha1@gmail.com Make sure that a CheckboxMenuButton doesn't crash in 0x0 environment (flutter/flutter#176450)
2025-10-10 Rusino@users.noreply.github.com [WebParagraph] Support for more styles, placeholders, decorations, etc (flutter/flutter#172853)
2025-10-10 jason-simmons@users.noreply.github.com Set up a version of build_ios_framework_module_test that only runs on x64 machines and extend its timeout (flutter/flutter#176811)
2025-10-10 engine-flutter-autoroll@skia.org Roll Packages from 0b41de3 to e319c40 (1 revision) (flutter/flutter#176833)
2025-10-10 danny@tuppeny.com [tool/dap] Forward app.warning events from Flutter to DAP client (flutter/flutter#176827)
2025-10-10 engine-flutter-autoroll@skia.org Roll Dart SDK from 70c00d3ceb3a to d88d8bf2b53c (1 revision) (flutter/flutter#176830)
2025-10-10 sokolovskyi.konstantin@gmail.com Remove unnecessary nullable types in examples. (flutter/flutter#176713)
2025-10-10 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from xArtL4DH0FsdwSqG_... to JpiUsek1hU5r9QVKP... (flutter/flutter#176822)
2025-10-10 bruno.leroux@gmail.com Cleanup OutlinedButton.icon documentation and implementation (flutter/flutter#176630)
2025-10-10 34871572+gmackall@users.noreply.github.com [HCPP] Properly remove hcpp views that are no longer visible (flutter/flutter#176742)
2025-10-10 ahmedsameha1@gmail.com Make sure that an InputChip doesn't crash in 0x0 environment (flutter/flutter#175930)
2025-10-10 737941+loic-sharma@users.noreply.github.com Update Flutter templates' Dart style (flutter/flutter#175963)
2025-10-10 ahmedsameha1@gmail.com Make sure that a DropdownButtonFormField doesn't crash in 0x0 environ… (flutter/flutter#174958)
2025-10-10 ahmedsameha1@gmail.com Make sure that an InkWell doesn't crash in 0x0 environment (flutter/flutter#175871)
2025-10-10 ahmedsameha1@gmail.com Handle#6537 end drawer button (flutter/flutter#173026)
2025-10-10 engine-flutter-autoroll@skia.org Roll Dart SDK from a9b7bd4b0b32 to 70c00d3ceb3a (4 revisions) (flutter/flutter#176815)
2025-10-10 robert.ancell@canonical.com Change default Linux thread policy to merge platform and UI threads. (flutter/flutter#176759)
2025-10-09 bkonyi@google.com [ Tool ] Roll package:dwds to 26.0.0 (flutter/flutter#176808)
2025-10-09 43054281+camsim99@users.noreply.github.com Update `CHANGELOG` to include 3.35.6 notes (flutter/flutter#176803)
2025-10-09 36861262+QuncCccccc@users.noreply.github.com Announce text and button together when DropdownMenu is treated as a button (flutter/flutter#176428)
2025-10-09 gregorysconrad@gmail.com [native_assets] create macOS CCompilerConfig via xcrun --find (flutter/flutter#175717)
2025-10-09 chinmaygarde@google.com [Impeller] Fix broken links in README. (flutter/flutter#176770)
2025-10-09 chinmaygarde@google.com Fix links to Custom Flutter Engine Embedders in README. (flutter/flutter#175807)
...
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
)

feat: apply radioGroup role to segmented control widgets
fixes: flutter#164589

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[a11y] apply radioGroup role to cupertino widgets

3 participants