Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] [Android] First TouchEffect Tap is not executed, if used inside TabView #1557

Open
Andreas0xffff opened this issue Aug 5, 2021 · 3 comments
Labels
a/TouchEffect bug Something isn't working. Breaky break. s/unverified This issue needs verification/reproduction by a team member. PRs cannot be accepted/merged.

Comments

@Andreas0xffff
Copy link
Contributor

Description

If TouchEffect is used in a ListView that is located on a TabViewItem, the first tap after a tab switch is not executed.

Steps to Reproduce

Replace the GalleryPageTemplate within the XCT samples app with this:

<ControlTemplate x:Key="GalleryPageTemplate">
            <StackLayout Spacing="0">
                <xct:TabView>
                    <xct:TabViewItem Text="A">
                <ListView
                    HasUnevenRows="True"
                    ItemsSource="{TemplateBinding BindingContext.FilteredItems}"
                    SelectionMode="None"
                    SeparatorVisibility="None">
                    <ListView.Header>
                        <ContentView Padding="20,12">
                            <Entry
                                HeightRequest="40"
                                IsTextPredictionEnabled="False"
                                Placeholder="Filter"
                                ReturnCommand="{TemplateBinding BindingContext.FilterCommand}"
                                ReturnType="Search"
                                Text="{TemplateBinding BindingContext.FilterValue,
                                                       Mode=OneWayToSource}" />
                        </ContentView>
                    </ListView.Header>
                    <ListView.Footer>
                        <BoxView HeightRequest="32" />
                    </ListView.Footer>
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <Grid Padding="20,12"
                                      xct:TouchEffect.NativeAnimation="True"
                                      xct:TouchEffect.Command="{Binding NavigateCommand, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}"
                                      xct:TouchEffect.CommandParameter="{Binding .}">
                                            <custom:PancakeView Style="{StaticResource card}">
                                                <!--<custom:PancakeView.GestureRecognizers>
                                                    <TapGestureRecognizer Command="{Binding NavigateCommand, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}" CommandParameter="{Binding .}" />
                                                </custom:PancakeView.GestureRecognizers>-->
                                                <Grid ColumnSpacing="20">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="12" />
                                                        <ColumnDefinition Width="*" />
                                                    </Grid.ColumnDefinitions>
                                                    <BoxView BackgroundColor="{Binding DetailColor, Source={x:RelativeSource AncestorType={x:Type ContentPage}}}" />
                                                    <StackLayout
                                                Grid.Column="1"
                                                Padding="0,24,24,24"
                                                Spacing="8">
                                                        <Label Style="{StaticResource label_section_header}" Text="{Binding Title}" />
                                                        <Label Text="{Binding Description}" />
                                                    </StackLayout>
                                                </Grid>
                                            </custom:PancakeView>
                                        </Grid>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                    </xct:TabViewItem>
                
                   <xct:TabViewItem Text="B">
                        <StackLayout>
                            <Label Text="Some Text"/>
                        </StackLayout>
                    </xct:TabViewItem>
                </xct:TabView>
            </StackLayout>
        </ControlTemplate>

Sample Video

Animation

Expected Behavior

The first Tap after the TabSwitch should not end with PlatformTouchEffect.android.cs/OnTouchCancel(), it should be executed with OnTouchUp().

Actual Behavior

The first Tap is lost.

Workaround

Insert
System.Threading.Thread.Sleep(100);
at the end of the OnTouchDown() function.
Alternatively use the InteractionStatusChanged event to Sleep a bit.

var te = (elem.Effects.FirstOrDefault() as TouchEffect);
if(te != null)
    te.InteractionStatusChanged += (object sender, TouchInteractionStatusChangedEventArgs ea)
		{
			if(ea.TouchInteractionStatus == TouchInteractionStatus.Started)
				System.Threading.Thread.Sleep(100);
		};
@Andreas0xffff Andreas0xffff added bug Something isn't working. Breaky break. s/unverified This issue needs verification/reproduction by a team member. PRs cannot be accepted/merged. labels Aug 5, 2021
@jfversluis
Copy link
Member

Thanks for the report! Does this only happen on Android? Have you also tested other platforms? What version of the library did you test with? Thanks!

@Andreas0xffff
Copy link
Contributor Author

iOS is okay:
Animation

I used the newest Main branch version. Latest Pull Commit #1558 / a09a14f.

@AndreiMisiukevich
Copy link
Contributor

Hey @Andreas0xffff thanks for your investigation.
Would you like to try to debug this and find the root cause?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/TouchEffect bug Something isn't working. Breaky break. s/unverified This issue needs verification/reproduction by a team member. PRs cannot be accepted/merged.
Projects
None yet
Development

No branches or pull requests

3 participants