Skip to content

Commit 434b81f

Browse files
authored
Fixing richMessage gesture recognizer in tooltip widget (#126207)
Fixing #126206 and #113388 issues *The IgnorePointer is preventing the richMessage touch events being recognized. Just removing that from* *Solves #126206 and #113388*
1 parent 682dd3b commit 434b81f

File tree

2 files changed

+48
-20
lines changed

2 files changed

+48
-20
lines changed

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

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -850,30 +850,28 @@ class _TooltipOverlay extends StatelessWidget {
850850

851851
@override
852852
Widget build(BuildContext context) {
853-
Widget result = IgnorePointer(
854-
child: FadeTransition(
855-
opacity: animation,
856-
child: ConstrainedBox(
857-
constraints: BoxConstraints(minHeight: height),
858-
child: DefaultTextStyle(
859-
style: Theme.of(context).textTheme.bodyMedium!,
860-
child: Container(
861-
decoration: decoration,
862-
padding: padding,
863-
margin: margin,
864-
child: Center(
865-
widthFactor: 1.0,
866-
heightFactor: 1.0,
867-
child: Text.rich(
868-
richMessage,
869-
style: textStyle,
870-
textAlign: textAlign,
871-
),
853+
Widget result = FadeTransition(
854+
opacity: animation,
855+
child: ConstrainedBox(
856+
constraints: BoxConstraints(minHeight: height),
857+
child: DefaultTextStyle(
858+
style: Theme.of(context).textTheme.bodyMedium!,
859+
child: Container(
860+
decoration: decoration,
861+
padding: padding,
862+
margin: margin,
863+
child: Center(
864+
widthFactor: 1.0,
865+
heightFactor: 1.0,
866+
child: Text.rich(
867+
richMessage,
868+
style: textStyle,
869+
textAlign: textAlign,
872870
),
873871
),
874872
),
875873
),
876-
)
874+
),
877875
);
878876
if (onEnter != null || onExit != null) {
879877
result = MouseRegion(

packages/flutter/test/material/tooltip_test.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,36 @@ void main() {
19061906
expect(find.byType(SizedBox), findsOneWidget);
19071907
}
19081908
});
1909+
1910+
testWidgetsWithLeakTracking('Tooltip should not ignore users tap on richMessage', (WidgetTester tester) async {
1911+
bool isTapped = false;
1912+
1913+
await tester.pumpWidget(
1914+
MaterialApp(
1915+
home: Tooltip(
1916+
richMessage: TextSpan(
1917+
text: tooltipText,
1918+
recognizer: TapGestureRecognizer()..onTap = () {
1919+
isTapped = true;
1920+
}
1921+
),
1922+
showDuration: const Duration(seconds: 5),
1923+
triggerMode: TooltipTriggerMode.tap,
1924+
child: const Icon(Icons.refresh)
1925+
),
1926+
),
1927+
);
1928+
1929+
final Finder tooltip = find.byType(Tooltip);
1930+
expect(find.text(tooltipText), findsNothing);
1931+
1932+
await _testGestureTap(tester, tooltip);
1933+
final Finder textSpan = find.text(tooltipText);
1934+
expect(textSpan, findsOneWidget);
1935+
1936+
await _testGestureTap(tester, textSpan);
1937+
expect(isTapped, isTrue);
1938+
});
19091939
}
19101940

19111941
Future<void> setWidgetForTooltipMode(

0 commit comments

Comments
 (0)