Skip to content

Commit 97a8e83

Browse files
authored
[a11y-app] Fix NavigationRail leading and trailing labels (flutter#174861)
## Description This PR adds a11y labels for the heading and trailing buttons of the NavigationRail use case (for the A11y assessments app). ## Related Issue Part of [[VPAT][A11y][a11y-app] controls in a11y assessment missing label](flutter#173051) ## Tests Adds 1 test.
1 parent 159b156 commit 97a8e83

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

dev/a11y_assessments/lib/use_cases/navigation_rail.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class _NavRailExampleState extends State<NavRailExample> {
5151
labelType: labelType,
5252
leading: showLeading
5353
? FloatingActionButton(
54+
tooltip: 'Add',
5455
elevation: 0,
5556
onPressed: () {
5657
// Add your onPressed code here!
@@ -60,6 +61,7 @@ class _NavRailExampleState extends State<NavRailExample> {
6061
: const SizedBox(),
6162
trailing: showTrailing
6263
? IconButton(
64+
tooltip: 'More',
6365
onPressed: () {
6466
// Add your onPressed code here!
6567
},

dev/a11y_assessments/test/navigation_rail_test.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,34 @@ void main() {
1414

1515
expect(find.byType(NavigationRail), findsExactly(1));
1616
});
17+
18+
testWidgets('navigation rail can show/hide leading', (WidgetTester tester) async {
19+
await pumpsUseCase(tester, NavigationRailUseCase());
20+
final Finder findLeading = find.byTooltip('Add');
21+
22+
expect(findLeading, findsNothing);
23+
24+
await tester.tap(find.text('Show Leading'));
25+
await tester.pump();
26+
expect(findLeading, findsOne);
27+
28+
await tester.tap(find.text('Hide Leading'));
29+
await tester.pump();
30+
expect(findLeading, findsNothing);
31+
});
32+
33+
testWidgets('navigation rail can show/hide trailing', (WidgetTester tester) async {
34+
await pumpsUseCase(tester, NavigationRailUseCase());
35+
final Finder findTrailing = find.byTooltip('More');
36+
37+
expect(findTrailing, findsNothing);
38+
39+
await tester.tap(find.text('Show Trailing'));
40+
await tester.pump();
41+
expect(findTrailing, findsOne);
42+
43+
await tester.tap(find.text('Hide Trailing'));
44+
await tester.pump();
45+
expect(findTrailing, findsNothing);
46+
});
1747
}

0 commit comments

Comments
 (0)