-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Fix: Delay showing tooltip during page transition #167614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
final ModalRoute<dynamic>? route = ModalRoute.of(context); | ||
if (route?.secondaryAnimation != null && route!.secondaryAnimation!.isAnimating) { | ||
_timer?.cancel(); | ||
_timer = Timer(route.transitionDuration, show); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to listen to when the animation ends and start the timer then? The current way isn't compatible with cases where this happens halfway during the transition or simulation-based transition where there isn't a predefined duration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yaa, was thinking the same. but for some reason below written code doesn't fix the issue.
if (route?.secondaryAnimation != null && route!.secondaryAnimation!.isAnimating) {
_timer?.cancel();
void onAnimationDismiss(AnimationStatus status) {
if (status == AnimationStatus.dismissed) {
route.secondaryAnimation!.removeStatusListener(onAnimationDismiss);
show();
}
}
route.secondaryAnimation!.addStatusListener(onAnimationDismiss);
return;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some cases the secondaryAnimation is swapped for a different one, so that may be why. The secondaryAnimation with the status listener is replaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than putting the logic here, should we have the check happen in tandem with the _visible
check for _ExclusiveMouseRegion
? So it ignores all mouse events while the route transitions are in motion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, that will be better place and we don't even need listener.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed the change, everything looks good. Thanks.
4ef9c09
to
0617cf1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for making this fix. Just left one tiny nit.
@@ -3478,6 +3479,48 @@ void main() { | |||
); | |||
expect(tester.element(textAncestors.first).size, equals(tooltipConstraints.biggest)); | |||
}); | |||
|
|||
testWidgets('Tooltip does not show while transitioning from another page', ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extreme nit, for this case I think it needs a link to the issue it is checking against.
testWidgets('Tooltip does not show while transitioning from another page', ( | |
// This is a regression test for https://github.com/flutter/flutter/issues/167359. | |
testWidgets('Tooltip does not show while transitioning from another page', ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggestion. Pushed the change.
0617cf1
to
910429c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Fix: Delay showing tooltip during page transition
fixes: #167359
Pre-launch Checklist
///
).