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

Removing TapGestureRecognizer with at least 2 taps causes Exception #21437

Closed
Matt-17 opened this issue Mar 25, 2024 · 1 comment · Fixed by #21714
Closed

Removing TapGestureRecognizer with at least 2 taps causes Exception #21437

Matt-17 opened this issue Mar 25, 2024 · 1 comment · Fixed by #21714
Labels
area-gestures Gesture types fixed-in-8.0.90 fixed-in-9.0.0-rc.1.24453.9 high It doesn't work at all, crashes or has a big impact. platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@Matt-17
Copy link

Matt-17 commented Mar 25, 2024

Description

When tapping a TapGestureRecognizer with NumberOfTapsRequired of at least 2, which will be removed inside the tap command, it will cause a NullReferenceException in InnerGestureListener.cs:65
Happens on Android emulator and my phones.

Steps to Reproduce

  1. Create a new MAUI App
  2. Replace content of MainPage.xaml <ContentPage> with
<VerticalStackLayout BindableLayout.ItemsSource="{Binding Items}" HorizontalOptions="Start">
    <BindableLayout.ItemTemplate>
        <DataTemplate x:DataType="system:String">
            <Label Text="{Binding .}" HorizontalOptions="Start">
                <Label.GestureRecognizers>
                    <TapGestureRecognizer NumberOfTapsRequired="2" Command="{Binding TapCommand, Source={RelativeSource AncestorType={x:Type local:MainPage}}}" CommandParameter="{Binding .}" />
                </Label.GestureRecognizers>
            </Label>
        </DataTemplate>
    </BindableLayout.ItemTemplate>
</VerticalStackLayout>
  1. Replace MainPage.xaml.cs with following:
public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        BindingContext = this;

    }
    public ObservableCollection<string> Items { get; } = ["Item 1", "Item 2", "Item 3"];

    public ICommand TapCommand => new Command<string>(obj =>
    {
        Items.Remove(obj);
    });
}
  1. Run app in Android
  2. double-tap Item 1, Item 2 or Item 3

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

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

No response

Did you find any workaround?

Inserting a short await Task.Delay() and then removing the entry works. Also going down to 1 required tap works as well.

Relevant log output

No response

@Matt-17 Matt-17 added the t/bug Something isn't working label Mar 25, 2024
@jsuarezruiz jsuarezruiz added area-gestures Gesture types platform/android 🤖 high It doesn't work at all, crashes or has a big impact. labels Mar 26, 2024
@jaosnz-rep
Copy link

Can repro this issue at Android platform on the latest 17.10 preview2 (8.0.14 & 8.0.6)

@jaosnz-rep jaosnz-rep added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Mar 26, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Apr 8, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jun 4, 2024
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
@samhouts samhouts added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 10, 2024
kubaflo added a commit to kubaflo/maui that referenced this issue Aug 16, 2024
PureWeen pushed a commit that referenced this issue Aug 17, 2024
…xception - fix (#21714)

* [Android] Added null checks (#21437)

* Updated test

* Updated test

* Update Issue21513.cs

---------

Co-authored-by: Javier Suárez <javiersuarezruiz@hotmail.com>
@github-actions github-actions bot locked and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-gestures Gesture types fixed-in-8.0.90 fixed-in-9.0.0-rc.1.24453.9 high It doesn't work at all, crashes or has a big impact. platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants