Skip to content
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

GestureDetector should not cancel a tap until finger moves off of button #19783

Open
matthew-carroll opened this issue Jul 25, 2018 · 8 comments
Labels
c: new feature Nothing broken; request for a new capability f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project team-framework Owned by Framework team triaged-framework Triaged by Framework team

Comments

@matthew-carroll
Copy link
Contributor

When a user taps on a button and then slides his/her finger around the button, if the finger moves more than the "slop" amount, the GestureDetector invokes onTapCancel. This behavior is not desired.

The desired behavior is that as long as the user's finger remains on the button, the button should remain pressed. Only upon dragging off the button should onTapCancel be invoked.

CC @Hixie

@zoechi zoechi added framework flutter/packages/flutter repository. See also f: labels. f: gestures flutter/packages/flutter/gestures repository. labels Jul 26, 2018
@HansMuller
Copy link
Contributor

HansMuller commented Jul 26, 2018

I think it's correct that the tap event is canceled if the pointer moves enough. On on the other hand we cancel the splash and press upon tapCancel() and that's not correct. The splash and pending press should only be canceled if the release event occurs outside of the button.

https://material.io/design/interaction/gestures.html doesn't appear to provide any guidance about this.

There seems to be some variation on exactly how native platforms handle dragging out of a button and then back in again. Android appears to cancel the press on drag-exit and does not restore it upon drag-enter. On IOS the drag-enter restores the button's pressed state.

I think we should do the right, platform-form specific, thing here.

@Hixie
Copy link
Contributor

Hixie commented Jul 26, 2018

I imagine this happening by having the GestureDetector pass the render object's size to the gesture recognizer when it changes (maybe only for tap).

@matthew-carroll
Copy link
Contributor Author

@HansMuller it depends how you want to define "correct." Neither Android nor iOS present the behavior you're referring to. Also, as a user, if I press down on a button, and I release anywhere on that button, I expect the button to execute its behavior.

You mentioned doing the right per-platform behavior. That sounds good. But I think it's clear that our current behavior isn't correct for either Android or iOS.

@HansMuller
Copy link
Contributor

I don't think GestureDetector needs to have the same behavior as buttons and other controls, it's just a simple low level "detector" after all. It's the wrong place for platform specific behavior.

@zoechi
Copy link
Contributor

zoechi commented Dec 21, 2018

Looks related to #11385

@iapicca iapicca added the c: new feature Nothing broken; request for a new capability label Mar 27, 2020
@mpfaff
Copy link

mpfaff commented Jun 14, 2020

Any update on this, or a workaround? I'm trying to use a GestureDetector to block something when the user's thumb isn't on a target and onTapCancel is called roughly every 15 seconds from tiny finger movements.

@rahai
Copy link

rahai commented Jul 6, 2020

@mpfaff

After going through a bunch of documentations for almost 2 days, I've found using a Listener widget instead of GestureDetector works for my case.

I put it up here just in case it might help anyone.

@mpfaff
Copy link

mpfaff commented Jul 12, 2020

@rahai thanks for mentioning that. I totally forgot about this thread after finding it myself, but I'm sure it will be useful for others in the future.

@goderbauer goderbauer added the P3 Issues that are less important to the Flutter project label Feb 21, 2023
@flutter-triage-bot flutter-triage-bot bot added team-framework Owned by Framework team triaged-framework Triaged by Framework team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: new feature Nothing broken; request for a new capability f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project team-framework Owned by Framework team triaged-framework Triaged by Framework team
Projects
None yet
Development

No branches or pull requests

8 participants