Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] Cannot scroll CollectionView when using SwipeView

Open awaescher opened this issue 2 years ago • 13 comments

Description

I was waiting for #12518 but it seems this update broke CollectionViews in combination with SwipeViews:

If you place a SwipeView onto a cell in a CollectionView like shown in the XAML-code below, scrolling vertically is not possible anymore.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage>
  <ContentPage.Resources>
    <DataTemplate x:Key="CardTemplate">
      <SwipeView
        Padding="8"
        HeightRequest="200">
        <SwipeView.RightItems>
          <SwipeItems>
            <SwipeItem
              Text="Delete"
              BackgroundColor="Red"
              IsDestructive="True" />
            </SwipeItems>
        </SwipeView.RightItems>
        <BoxView BackgroundColor="Bisque" />
      </SwipeView>
    </DataTemplate>
  </ContentPage.Resources>
  <CollectionView
    ItemTemplate="{StaticResource CardTemplate}"
    ItemsSource="{Binding Collections}" />
  </ContentPage>

With Xamarin.Forms 5.0.0.2083 this worked perfectly (but the swipe recognizer was too sensitive #12518) as you can see in the first video below.

Since Xamarin.Forms 5.0.0.2125, the CollectionView cannot be scrolled on a certain cell. You have to hit the spacing in between as you can see in the second video below. Alternatively I could set InputTransparent=True to all the views on the cell template but that would prevent using the SwipeView again.

Expected Behavior

Scrolling is possible on any view on the CollectionView.

Actual Behavior

Scrolling is only possible when started between the cell views.

Basic Information

  • Version with issue: 5.0.0.2125
  • Last known good version: 5.0.0.2083
  • Platform Target Frameworks:
    • iOS: Xcode 12.5.1 (12E507)
    • Android: Not tested
    • UWP: Not tested
  • NuGet Packages:
  • Affected Devices: All iOS Simulators

Environment

Show/Hide Visual Studio info
=== Visual Studio Community 2019 for Mac ===

Version 8.10.9 (build 3)
Installation UUID: 65f25c7e-862d-4c81-972c-3562ca017ab1
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

	Package version: 612000140

=== Mono Framework MDK ===

Runtime:
	Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit)
	Package version: 612000140

=== Xamarin Designer ===

Version: 16.10.0.119
Hash: 36a2d986f
Branch: remotes/origin/d16-10
Build date: 2021-06-02 19:41:34 UTC

=== Roslyn (Language Service) ===

3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb

=== NuGet ===

Version: 5.9.0.7134

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.401/Sdks
SDK Versions:
	5.0.401
	5.0.400
	5.0.301
	5.0.203
	5.0.202
	5.0.201
	5.0.103
	5.0.102
	5.0.101
	5.0.100
	3.1.413
	3.1.412
	3.1.410
	3.1.409
	3.1.408
	3.1.407
	3.1.406
	3.1.405
	3.1.404
	3.1.403
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	5.0.10
	5.0.9
	5.0.7
	5.0.6
	5.0.5
	5.0.4
	5.0.3
	5.0.2
	5.0.1
	5.0.0
	3.1.19
	3.1.18
	3.1.16
	3.1.15
	3.1.14
	3.1.13
	3.1.12
	3.1.11
	3.1.10
	3.1.9

=== .NET Core 3.1 SDK ===

SDK: 3.1.413

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 12.5.1 (18212)
Build 12E507

=== Xamarin.Mac ===

Version: 7.14.0.24 (Visual Studio Community)
Hash: c4b89cddb
Branch: d16-10
Build date: 2021-06-15 22:03:00-0400

=== Xamarin.iOS ===

Version: 14.20.0.24 (Visual Studio Community)
Hash: c4b89cddb
Branch: d16-10
Build date: 2021-06-15 22:03:01-0400

=== Xamarin.Android ===

Not Installed

=== Microsoft OpenJDK for Mobile ===

Java SDK: Not Found

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.10.0.13
Hash: 1b81df5
Branch: remotes/origin/d16-10
Build date: 2021-08-12 20:43:52 UTC

=== Android Device Manager ===

Version: 16.10.0.15
Hash: 89dcc0b
Branch: remotes/origin/d16-10
Build date: 2021-08-12 20:44:10 UTC

=== Build Information ===

Release ID: 810090003
Git revision: 156eb53c9c668cb7ff4311ae3d1dab894549848b
Build date: 2021-09-08 07:26:54-04
Build branch: release-8.10

=== Operating System ===

Mac OS X 10.16.0
Darwin 20.6.0 Darwin Kernel Version 20.6.0
    Wed Jun 23 00:26:27 PDT 2021
    root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 x86_64

Screenshots

https://user-images.githubusercontent.com/3630638/134145881-ceb16301-49d4-465e-9133-a89bc763adda.mov

https://user-images.githubusercontent.com/3630638/134145905-a316ad7f-974c-43b1-84c7-9fa72a387377.mov

awaescher avatar Sep 21 '21 10:09 awaescher

@awaescher Could you attach a small sample where reproduce the issue?. Thanks!

jsuarezruiz avatar Sep 21 '21 12:09 jsuarezruiz

:( again ...

decv86 avatar Oct 23 '21 21:10 decv86

The problem still exists. See the attachment for an example project. When you downgrade XF to version 5.0.0.2083 scrolling works as expected. DemoSwipeIssue.zip

vanhaperen avatar Feb 01 '22 10:02 vanhaperen

Still broken.

Hooterr avatar May 24 '22 14:05 Hooterr

@jfversluis or @jsuarezruiz Could we bring some attention to this bug?! I know Maui is the new cool thing, but XF is in production use. Using SwipeView in CollectionView is a very common use case.

AlleSchonWeg avatar May 25 '22 08:05 AlleSchonWeg

I think it may have something to do with the gesture recognizers in the scrollview. I had a similar issue with the Andreii Miskivich's CoverFlowView being put in a scroll view.

Hooterr avatar May 25 '22 12:05 Hooterr

For anyone interested, I found a workaround. App.Current.On<iOS>().SetPanGestureRecognizerShouldRecognizeSimultaneously(true); Put it in your code-behind. Explanataion: https://docs.microsoft.com/nl-be/xamarin/xamarin-forms/platform/ios/application-pan-gesture Not sure if it can unintentionally break other stuff in your app, so far I haven't noticed any issues.

Hooterr avatar May 26 '22 21:05 Hooterr

In the simulator the problem is not easy to reproduce. Most of the time it works. On a real device (iOS 15.4.1) the view freeze if you open a swipeview, hold finger down, move up fast and then fast down. I tried hooterrs workaround and also downgrade XF to 5.0.0.2083. But the problem on a real device stay.

AlleSchonWeg avatar May 30 '22 12:05 AlleSchonWeg

I'm on XF 5.0.0.2478 and the issue still persists. Tried the workaround SetPanGestureRecognizerShouldRecognizeSimultaneously but it doesn't work. Do you need any more info other than the example project provided in the above comments? If so, I can help with that.

fedemkr avatar Sep 12 '22 15:09 fedemkr

Same. SetPanGestureRecognizerShouldRecognizeSimultaneously does not help. Any solutions?

Alexbits avatar Feb 08 '23 18:02 Alexbits

Same. SetPanGestureRecognizerShouldRecognizeSimultaneously does not help. Any solutions?

We ended up with a custom renderer for this and used the old implementation for ShouldRecognizeSimultaneously in UIPanGestureRecognizer

panGestureRecognizer.ShouldRecognizeSimultaneously = (_, _) => true;

xedunpax avatar Aug 21 '23 17:08 xedunpax

Same. SetPanGestureRecognizerShouldRecognizeSimultaneously does not help. Any solutions?

We ended up with a custom renderer for this and used the old implementation for ShouldRecognizeSimultaneously in UIPanGestureRecognizer

panGestureRecognizer.ShouldRecognizeSimultaneously = (_, _) => true;

Hi, is this working for you? You create a custom renderer SwipeViewRenderer an override the default behavior? https://github.com/xamarin/Xamarin.Forms/blob/a979cd28bf9dd59b33c390b617e120420f2f977d/Xamarin.Forms.Platform.iOS/Renderers/SwipeViewRenderer.cs#L70 Thx

AlleSchonWeg avatar Aug 22 '23 07:08 AlleSchonWeg

Had the same issue using Xamarin.Forms v5.0.0.2622. The workaround mentioned by @xedunpax fixed it for me. My custom renderer looks like this:

public class CustomSwipeViewRenderer : SwipeViewRenderer
{
    public CustomSwipeViewRenderer()
        : base()
    {
        var recognizer = this.GestureRecognizers.Where(g =>
        {
            return g is UIPanGestureRecognizer;
        }).FirstOrDefault();

        recognizer.ShouldRecognizeSimultaneously = (gr1, gr2) => {
            return true;
        };
    }
}

DennisTheD avatar Jan 09 '24 11:01 DennisTheD