Open sjordanGSS opened 3 months ago
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!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
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.
I've done some digging on this and tracked the bug down to this section of code: https://github.com/dotnet/maui/blob/d6cb19d9c99514eaec28c6b21357f4e5118684ba/src/Core/src/Platform/Android/MauiSwipeView.cs#L101
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
Description
When a
SwipeView
is swiped, it can be tapped to close. However, this tap will also activateTapGestureRecognizer
s attached to theContent
viewsPlease 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
Label
left or rightTapGestureRecognizer
attached to theLabel
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
andSwipeViewItem.Tapped
to set theContent
'sIsEnabled
to false while the view is swiped, however this will malfunction if theSwipeView
is closed with a long press.I tried wrapping the
Label
in aContentView
to see if this issue was exclusive to the immediate children of theSwipeView
, however it had no effect.Relevant log output
No response