Skip to content

Commit 1cdc73e

Browse files
authored
[material_ui] Removes list semantics in some a11y_assessment samples (flutter#13257)
fixes flutter#194237 fixes flutter#194248 Android creates collection info based on semantics child count and index, which causes talkback to announce the 1 of n when item is focused. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 30d67e6 commit 1cdc73e

20 files changed

Lines changed: 107 additions & 4 deletions

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/check_box.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class _MainWidgetState extends State<_MainWidget> {
3737
return Scaffold(
3838
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
3939
body: ListView(
40+
semanticChildCount: 0,
41+
addSemanticIndexes: false,
4042
children: <Widget>[
4143
Checkbox(
4244
value: _checked,

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/dropdown_menu.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class _MainWidget extends StatelessWidget {
3939
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
4040
body: ListView(
4141
padding: const EdgeInsets.all(24.0),
42+
semanticChildCount: 0,
43+
addSemanticIndexes: false,
4244
children: <Widget>[
4345
Semantics(
4446
label: 'Enabled dropdown menu',

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/menu_anchor.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class _MainWidgetState extends State<_MainWidget> {
3838
return Scaffold(
3939
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
4040
body: ListView(
41+
semanticChildCount: 0,
42+
addSemanticIndexes: false,
4143
children: <Widget>[
4244
Semantics(liveRegion: true, child: Text('Last Selection: $_lastSelection')),
4345
Semantics(

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/menu_bar.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class _MainWidgetState extends State<_MainWidget> {
3838
return Scaffold(
3939
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
4040
body: ListView(
41+
semanticChildCount: 0,
42+
addSemanticIndexes: false,
4143
children: <Widget>[
4244
Semantics(liveRegion: true, child: Text('Last Selection: $_lastSelection')),
4345
Semantics(

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/search_bar.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class _MainWidgetState extends State<_MainWidget> {
8989
return Scaffold(
9090
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
9191
body: ListView(
92+
semanticChildCount: 0,
93+
addSemanticIndexes: false,
9294
children: <Widget>[
9395
Semantics(
9496
label: 'Enabled search bar',

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/switch.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class _MainWidgetState extends State<_MainWidget> {
3737
return Scaffold(
3838
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
3939
body: ListView(
40+
semanticChildCount: 0,
41+
addSemanticIndexes: false,
4042
children: <Widget>[
4143
Semantics(
4244
label: 'Enabled switch',

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/text_field.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class _MainWidget extends StatelessWidget {
3232
return Scaffold(
3333
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
3434
body: ListView(
35+
semanticChildCount: 0,
36+
addSemanticIndexes: false,
3537
children: <Widget>[
3638
const TextField(
3739
key: Key('enabled text field'),

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/text_field_password.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class _MainWidget extends StatelessWidget {
3232
return Scaffold(
3333
appBar: AppBar(title: Semantics(headingLevel: 1, child: Text('$pageTitle Demo'))),
3434
body: ListView(
35+
semanticChildCount: 0,
36+
addSemanticIndexes: false,
3537
children: const <Widget>[
3638
TextField(
3739
key: Key('enabled password'),

‎packages/material_ui/test_apps/a11y_assessments/lib/use_cases/text_form_field.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class _MainWidgetState extends State<_MainWidget> {
3939
body: Form(
4040
key: _formKey,
4141
child: ListView(
42+
semanticChildCount: 0,
43+
addSemanticIndexes: false,
4244
children: <Widget>[
4345
Semantics(
4446
label: 'Enabled text form field',

‎packages/material_ui/test_apps/a11y_assessments/test/check_box_list_tile_test.dart‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,11 @@ void main() {
3030
await tester.pumpAndSettle();
3131
expect(findHeadingLevelOnes, findsOne);
3232
});
33+
34+
testWidgets('check box list tile use case content is a semantic list', (
35+
WidgetTester tester,
36+
) async {
37+
await pumpsUseCase(tester, CheckBoxListTile());
38+
expect(hasSemanticsList(tester, find.byType(ListView)), isTrue);
39+
});
3340
}

0 commit comments

Comments
 (0)