material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[SwipeDismissBehavior]fix SwipeDissmissBehavior not work when down touch event consumed by …

Open kingwang666 opened this issue 2 years ago • 1 comments

Fix #1333 This bug is caused by two reasons

  1. Recieving a ACTION_CANCEL event from the CoordinatorLayout when the SwipeDismissBehavior calls requestDisallowInterceptTouchEvent in onViewCaptured.
  2. ACTION_DOWN consumed by other view, causing the Behavior not to call back onTouchEvent

kingwang666 avatar Aug 03 '22 11:08 kingwang666

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Aug 03 '22 11:08 google-cla[bot]

I approved cuz' I didn't see the error mentioned in the issue with this change. But when I took another look, I cannot repro the error messages with the current snapshot. It seems it got fixed at some point (the issue has a bit history now). Could you confirm? If so, I'll close this PR and the issue.

pekingme avatar Sep 28 '22 22:09 pekingme

I approved cuz' I didn't see the error mentioned in the issue with this change. But when I took another look, I cannot repro the error messages with the current snapshot. It seems it got fixed at some point (the issue has a bit history now). Could you confirm? If so, I'll close this PR and the issue.

@pekingme Hello, I tested and it still exists. You can use CardSwipeDismissFragment to test it. set OnClickListener to cardContentLayout. The ACTION_DOWN consumed by cardContentLayout

cardContentLayout.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
    
  }
});

The last master code.

https://user-images.githubusercontent.com/16848272/192931246-1ab78794-032f-4611-8c8f-b88b8b491acf.mp4

After set onClickListener.

https://user-images.githubusercontent.com/16848272/192931539-263317a9-0515-4ff6-afd0-7bedf1b6a651.mp4

After fixed.

https://user-images.githubusercontent.com/16848272/192931656-2b074c1f-7bb5-4e17-942e-bb3744f9e4e5.mp4

kingwang666 avatar Sep 29 '22 03:09 kingwang666

Thanks for the recording! Yes, I can reproduce the same behavior with the catalog built externally. Was testing with the catalog built internally. It seems the fix works well with androidx.coordinatorlayout:coordinatorlayout:1.1.0. But we use a more recent version. If you update androidx.coordinatorlayout:coordinatorlayout to 1.2.0, the fix won't work anymore.

I don't see any regression with this fix internally. Let me test this out a bit more. Meanwhile I'm looking for a fix that works with the 1.2.0 and above now. Let me know if you find anything. TIA

pekingme avatar Oct 03 '22 21:10 pekingme

Ok, I have updated the fix (internally) to make it works for both 1.1.0 and later version. Should be merged soon.

pekingme avatar Oct 04 '22 20:10 pekingme

@pekingme ok~

kingwang666 avatar Oct 11 '22 02:10 kingwang666