Skip to content

Commit d263cfb

Browse files
authored
Fix BottomNavigationBarItem tooltip defaults to label (#107715)
1 parent ebb9128 commit d263cfb

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

packages/flutter/lib/src/material/bottom_navigation_bar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class _BottomNavigationTile extends StatelessWidget {
455455
final double unselectedIconDiff = math.max(unselectedIconSize - selectedIconSize, 0);
456456

457457
// The effective tool tip message to be shown on the BottomNavigationBarItem.
458-
final String? effectiveTooltip = item.tooltip == '' ? null : item.tooltip ?? item.label;
458+
final String? effectiveTooltip = item.tooltip == '' ? null : item.tooltip;
459459

460460
// Defines the padding for the animating icons + labels.
461461
//

packages/flutter/lib/src/widgets/bottom_navigation_bar_item.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,10 @@ class BottomNavigationBarItem {
8181
/// the icons themselves.
8282
final Color? backgroundColor;
8383

84-
/// The text to display in the tooltip for this [BottomNavigationBarItem], when
85-
/// the user long presses the item.
84+
/// The text to display in the [Tooltip] for this [BottomNavigationBarItem].
8685
///
87-
/// The [Tooltip] will only appear on an item in a Material design [BottomNavigationBar], and
88-
/// when the string is not empty.
86+
/// A [Tooltip] will only appear on this item if `tooltip` is set to a non-empty string.
8987
///
90-
/// Defaults to null, in which case the [label] text will be used.
88+
/// Defaults to null, in which case the tooltip is not shown.
9189
final String? tooltip;
9290
}

packages/flutter/test/material/bottom_navigation_bar_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ void main() {
12091209

12101210
expect(find.text('B'), findsOneWidget);
12111211
await tester.longPress(find.text('B'));
1212-
expect(find.byTooltip('B'), findsOneWidget);
1212+
expect(find.byTooltip('B'), findsNothing);
12131213

12141214
expect(find.text('C'), findsOneWidget);
12151215
await tester.longPress(find.text('C'));

0 commit comments

Comments
 (0)