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

Tapping to close a SwipeView will activate TapGestureRecognizers on .Content #23921

Open
sjordanGSS opened this issue Jul 30, 2024 · 3 comments · May be fixed by #24275
Open

Tapping to close a SwipeView will activate TapGestureRecognizers on .Content #23921

sjordanGSS opened this issue Jul 30, 2024 · 3 comments · May be fixed by #24275
Labels
Milestone

Comments

@sjordanGSS
Copy link

sjordanGSS commented Jul 30, 2024

Description

When a SwipeView is swiped, it can be tapped to close. However, this tap will also activate TapGestureRecognizers attached to the Content views

Please note that although I have not tested other .NET MAUI versions, this bug is present in Xamarin.Forms. I have recently revisited a project based upon Xamarin.Forms 5 that includes the workaround stated below.

Steps to Reproduce

  • Download and run the reproduction
  • Swipe the Label left or right
  • Tap to close
  • The text "content tapped" will be printed to the debug output, to indicate that the TapGestureRecognizer attached to the Label has been activated.

Link to public reproduction project repository

https://github.com/sjordanGSS/swipeview-content-gesture

Version with bug

8.0.70 SR7, 8.0.61 SR6

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Tested and reproduced on Android 7.1, 10, 11, 14

Did you find any workaround?

Code can be added to SwipeView.SwipeEnded and SwipeViewItem.Tapped to set the Content's IsEnabled to false while the view is swiped, however this will malfunction if the SwipeView is closed with a long press.

I tried wrapping the Label in a ContentView to see if this issue was exclusive to the immediate children of the SwipeView, however it had no effect.

Relevant log output

No response

@sjordanGSS sjordanGSS added the t/bug Something isn't working label Jul 30, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@sjordanGSS
Copy link
Author

I have updated the repro to include both a Label and a Button in a VerticalStackLayout as the SwipeView's content. Tapping to close the SwipeView over either of these controls will cause their Tapped or Clicked event handlers respectively to be invoked.

@sjordanGSS
Copy link
Author

sjordanGSS commented Aug 15, 2024

I've done some digging on this and tracked the bug down to this section of code:

SwipeDirection swipeDirection;

			if (Math.Abs(diffX) > Math.Abs(diffY))
				swipeDirection = diffX > 0 ? SwipeDirection.Right : SwipeDirection.Left;
			else
				swipeDirection = diffY > 0 ? SwipeDirection.Down : SwipeDirection.Up;

If both diff values are zero (as they are when the swipeview is tapped), SwipeDirection.Up will always be chosen. If no UpItems are set then this code

			var items = GetSwipeItemsByDirection(swipeDirection);

			if (items == null || items?.Count == 0)
				return false;

will return false. Adding

    if(diffX == 0 && diffY == 0)
      return _isOpen;

before the first section would resolve this issue. I have already tested this in my own project and verified that it resolves this issue. I may have some time tomorrow to submit a pr here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants