From d263cfbcb5bf6917d25a5bb99a7802a76969dac3 Mon Sep 17 00:00:00 2001 From: Bruno Leroux Date: Thu, 21 Jul 2022 06:21:05 +0200 Subject: [PATCH] Fix BottomNavigationBarItem tooltip defaults to label (#107715) --- .../flutter/lib/src/material/bottom_navigation_bar.dart | 2 +- .../lib/src/widgets/bottom_navigation_bar_item.dart | 8 +++----- .../flutter/test/material/bottom_navigation_bar_test.dart | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 82e05b756bf..5635c561f32 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -455,7 +455,7 @@ class _BottomNavigationTile extends StatelessWidget { final double unselectedIconDiff = math.max(unselectedIconSize - selectedIconSize, 0); // The effective tool tip message to be shown on the BottomNavigationBarItem. - final String? effectiveTooltip = item.tooltip == '' ? null : item.tooltip ?? item.label; + final String? effectiveTooltip = item.tooltip == '' ? null : item.tooltip; // Defines the padding for the animating icons + labels. // diff --git a/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart b/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart index 41f181992d7..f710fa6270c 100644 --- a/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart +++ b/packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart @@ -81,12 +81,10 @@ class BottomNavigationBarItem { /// the icons themselves. final Color? backgroundColor; - /// The text to display in the tooltip for this [BottomNavigationBarItem], when - /// the user long presses the item. + /// The text to display in the [Tooltip] for this [BottomNavigationBarItem]. /// - /// The [Tooltip] will only appear on an item in a Material design [BottomNavigationBar], and - /// when the string is not empty. + /// A [Tooltip] will only appear on this item if `tooltip` is set to a non-empty string. /// - /// Defaults to null, in which case the [label] text will be used. + /// Defaults to null, in which case the tooltip is not shown. final String? tooltip; } diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 29e7f5b47bf..559a4abdca8 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -1209,7 +1209,7 @@ void main() { expect(find.text('B'), findsOneWidget); await tester.longPress(find.text('B')); - expect(find.byTooltip('B'), findsOneWidget); + expect(find.byTooltip('B'), findsNothing); expect(find.text('C'), findsOneWidget); await tester.longPress(find.text('C'));