-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix tooltips don't dismiss when using TooltipTriggerMode.tap #103960
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
Fix tooltips don't dismiss when using TooltipTriggerMode.tap #103960
Conversation
a0e7e6c to
bfa3023
Compare
chunhtai
left a comment
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.
Based on the pr description, the issue is that the global pointer arrive faster than the ontap call back which makes the _handleMouseExit called before the _handleTap is called?
If so it seems like we should not use the globalpointer route in the first place, why don't we just use the onLongPressUp/onLongPressCancel and onTapUp/onTapCancel to call the _handleMouseExit?
|
@chunhtai Thanks for the review.
Yes, that's the issue.
I think the global pointer route was used for the main following reason : from the material spec, "If the user takes another action before that time ends, the tooltip will disappear.". For instance, if the showDuration is set to 3 seconds, the user can dismiss the tooltip before this delay with a tap anywhere, this 'action' will be catch by the PointerRouter. |
|
Thanks for clarifying, based on the original issue it seems like only this is required
the PointerUpEvent, PointerCancelEvent should be handled by the gesture detector instead? |
|
The reason I brought this up is this pr create two different ways to dismiss the tooltip for longpress and tap, one from the global route for long press and one from the ontap handler for single tap, It will be easier to maintain if they are more unified. |
|
Unification would be great. Unfortunately, I don’t think we can get rid of PointerRouter reacting to PointerUpEvent/PointerCancelEvent. I tried and quickly found one issue on Desktop : hold down the mouse button outside the widget, move above the widget, the tooltip is shown (onMouseOver), release the button the tooltip should be dismissed, it is not when removing this line :
and we can't rely on GestureDetector for this scenario because the gesture started elsewhere. As TooltipTriggerMode.tap was introduced recently (in 2021) and is not covered by Material spec, I tried to find a fix that doesn’t interfere with the main use cases (longPress and Hover) to avoid subtle breaking changes. |
Is this a expected behavior? I tried on web https://www.w3schools.com/css/tryit.asp?filename=trycss_tooltip |
As per material spec, I would say yes
By default no. I too expected that it will, for instance on desktop. That's why I filed #103703. What you suggest is smarter : using mouse hover when a mouse is connected and relying on gestures when there are no mouse. That seems very interesting for computer with a touch screen or tablets with a mouse. If it makes sense, filing a new issue will be more actionnable than updating this PR. I would like to keep this PR simple, as
|
chunhtai
left a comment
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, make sense. seem like the best thing to do at the moment
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.
can you add some comments around globalpointer route may be called faster than the the gesture recognizer and why this is here.
d01fcf4 to
a4b7329
Compare
|
This pull request is not suitable for automatic merging in its current state.
|
a4b7329 to
89bada8
Compare
Description
Tooltips lifecycle is managed using three sources of pointer events :
MouseRegionto manage hover events.GestureBinding.instance.pointerRouter.GestureDetectorto react to long press or tap gestures (depending on the tooltip trigger mode).The GestureDetector handlers (onLongPress and onTap) call _handlePress method to display the Tooltip.
The tooltip is dismissed either by :
For TooltipTriggerMode.onTap, the tooltip might not be disposed (see #98854). It happens when there is one or more competing GestureDetectors. In this case (see #98854), the GestureArena disambiguation process takes more time and the PointerRouter events are received before the tooltip is shown.
This PR updates the Tooltip GestureDetector onTap callback to show the Tooltip and dismisses it after
showDurationexpired.Related Issue
Fixes #98854
Tests
Add 3 test in
material/tooltip_test.dartPre-launch Checklist
///).