Skip to content

Commit

Permalink
Fixing richMessage gesture recognizer in tooltip widget (#126207)
Browse files Browse the repository at this point in the history
Fixing #126206 and #113388 issues

*The IgnorePointer is preventing the richMessage touch events being recognized. Just removing that from*

*Solves #126206 and #113388*
  • Loading branch information
mhbdev committed May 18, 2023
1 parent 682dd3b commit 434b81f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
38 changes: 18 additions & 20 deletions packages/flutter/lib/src/material/tooltip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -850,30 +850,28 @@ class _TooltipOverlay extends StatelessWidget {

@override
Widget build(BuildContext context) {
Widget result = IgnorePointer(
child: FadeTransition(
opacity: animation,
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: height),
child: DefaultTextStyle(
style: Theme.of(context).textTheme.bodyMedium!,
child: Container(
decoration: decoration,
padding: padding,
margin: margin,
child: Center(
widthFactor: 1.0,
heightFactor: 1.0,
child: Text.rich(
richMessage,
style: textStyle,
textAlign: textAlign,
),
Widget result = FadeTransition(
opacity: animation,
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: height),
child: DefaultTextStyle(
style: Theme.of(context).textTheme.bodyMedium!,
child: Container(
decoration: decoration,
padding: padding,
margin: margin,
child: Center(
widthFactor: 1.0,
heightFactor: 1.0,
child: Text.rich(
richMessage,
style: textStyle,
textAlign: textAlign,
),
),
),
),
)
),
);
if (onEnter != null || onExit != null) {
result = MouseRegion(
Expand Down
30 changes: 30 additions & 0 deletions packages/flutter/test/material/tooltip_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,36 @@ void main() {
expect(find.byType(SizedBox), findsOneWidget);
}
});

testWidgetsWithLeakTracking('Tooltip should not ignore users tap on richMessage', (WidgetTester tester) async {
bool isTapped = false;

await tester.pumpWidget(
MaterialApp(
home: Tooltip(
richMessage: TextSpan(
text: tooltipText,
recognizer: TapGestureRecognizer()..onTap = () {
isTapped = true;
}
),
showDuration: const Duration(seconds: 5),
triggerMode: TooltipTriggerMode.tap,
child: const Icon(Icons.refresh)
),
),
);

final Finder tooltip = find.byType(Tooltip);
expect(find.text(tooltipText), findsNothing);

await _testGestureTap(tester, tooltip);
final Finder textSpan = find.text(tooltipText);
expect(textSpan, findsOneWidget);

await _testGestureTap(tester, textSpan);
expect(isTapped, isTrue);
});
}

Future<void> setWidgetForTooltipMode(
Expand Down

0 comments on commit 434b81f

Please sign in to comment.