From 1427fef8f8ce525ef3c0e369f85849243b3a4767 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 14 Jun 2019 14:47:54 -0700 Subject: [PATCH] Make sure fab semantics end up on top (#34512) --- .../lib/src/material/floating_action_button.dart | 10 ++++------ .../material/floating_action_button_test.dart | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/flutter/lib/src/material/floating_action_button.dart b/packages/flutter/lib/src/material/floating_action_button.dart index 0c45c56c05b..3100a5729a5 100644 --- a/packages/flutter/lib/src/material/floating_action_button.dart +++ b/packages/flutter/lib/src/material/floating_action_button.dart @@ -462,11 +462,9 @@ class FloatingActionButton extends StatelessWidget { ); if (tooltip != null) { - result = MergeSemantics( - child: Tooltip( - message: tooltip, - child: result, - ), + result = Tooltip( + message: tooltip, + child: result, ); } @@ -477,7 +475,7 @@ class FloatingActionButton extends StatelessWidget { ); } - return result; + return MergeSemantics(child: result); } @override diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index c644ead2f97..b6e0448ab33 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -763,6 +763,22 @@ void main() { paintsExactlyCountTimes(#clipPath, 0), ); }); + + testWidgets('Can find FloatingActionButton semantics', (WidgetTester tester) async { + await tester.pumpWidget(MaterialApp( + home: FloatingActionButton(onPressed: () {}), + )); + + expect( + tester.getSemantics(find.byType(FloatingActionButton)), + matchesSemantics( + hasTapAction: true, + hasEnabledState: true, + isButton: true, + isEnabled: true, + ), + ); + }, semanticsEnabled: true); } Offset _rightEdgeOfFab(WidgetTester tester) {