From d4cffa25402d9a26d4eeee7704e69b0cda4a7da8 Mon Sep 17 00:00:00 2001 From: hangyu Date: Fri, 21 Jun 2024 14:48:41 -0700 Subject: [PATCH] [a11y] Update semantics in bottom_navigation_bar.dart (#150576) issue: https://github.com/flutter/flutter/issues/117997 ## 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. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --- .../lib/src/material/bottom_navigation_bar.dart | 1 + .../material/bottom_navigation_bar_test.dart | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 0f9cf05692..6e78778812 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -605,6 +605,7 @@ class _BottomNavigationTile extends StatelessWidget { result = Semantics( selected: selected, + button: true, container: true, child: Stack( children: [ diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index f0e65837bb..ea25635457 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -2108,6 +2108,7 @@ void main() { matchesSemantics( label: 'AC\nTab 1 of 3', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, isSelected: true, hasTapAction: true, @@ -2119,6 +2120,7 @@ void main() { matchesSemantics( label: 'Alarm\nTab 2 of 3', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true, @@ -2129,6 +2131,7 @@ void main() { matchesSemantics( label: 'Hot Tub\nTab 3 of 3', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true, @@ -2165,6 +2168,7 @@ void main() { matchesSemantics( label: 'AC\nTab 1 of 3', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, isSelected: true, hasTapAction: true, @@ -2176,6 +2180,7 @@ void main() { matchesSemantics( label: 'Alarm\nTab 2 of 3', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true, @@ -2186,6 +2191,7 @@ void main() { matchesSemantics( label: 'Hot Tub\nTab 3 of 3', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true, @@ -2518,6 +2524,7 @@ void main() { matchesSemantics( label: 'Red\nTab 1 of 2', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, isSelected: true, hasTapAction: true, @@ -2529,6 +2536,7 @@ void main() { matchesSemantics( label: 'Green\nTab 2 of 2', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true, @@ -2563,6 +2571,7 @@ void main() { matchesSemantics( label: 'Red\nTab 1 of 2', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, isSelected: true, hasTapAction: true, @@ -2574,6 +2583,7 @@ void main() { matchesSemantics( label: 'Green\nTab 2 of 2', textDirection: TextDirection.ltr, + isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true, @@ -2754,6 +2764,7 @@ void main() { children: [ TestSemantics( flags: [ + SemanticsFlag.isButton, SemanticsFlag.isSelected, SemanticsFlag.isFocusable, ], @@ -2762,7 +2773,10 @@ void main() { textDirection: TextDirection.ltr, ), TestSemantics( - flags: [SemanticsFlag.isFocusable], + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.isFocusable, + ], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'B\nTab 2 of 2', textDirection: TextDirection.ltr,