-
Notifications
You must be signed in to change notification settings - Fork 461
Description
Is there an existing issue for this?
- I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
When using TouchBehavior to handle both tap and long‑press gestures on the same control, the events/commands overlap in unexpected ways.
-
If you attach both TouchGestureCompleted and LongPressCompleted, a long press triggers both handlers.
-
If you mix TapGestureRecognizer with TouchBehavior.LongPressCommand, sometimes a long press also triggers a tap, or two quick taps are mis‑interpreted as a long press.
This makes it difficult to reliably distinguish between a quick tap and a long press.
Expected Behavior
Expected behavior
Quick tap → only OnTapCompleted fires.
Long press → only OnLongPressCompleted fires.
Steps To Reproduce
Reproduction
MainPage.xaml
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="TouchBugDemo.MainPage">
<Grid Padding="40">
<Grid.Behaviors>
<toolkit:TouchBehavior
LongPressDuration="5000"
TouchGestureCompleted="OnTapCompleted"
LongPressCompleted="OnLongPressCompleted" />
</Grid.Behaviors>
<Border Stroke="Gray" StrokeThickness="2" Padding="20">
<Label Text="Tap or Long Press me"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Border>
</Grid>
</ContentPage>
MainPage.xaml.cs
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnTapCompleted(object sender, EventArgs e)
{
Console.WriteLine("Tap fired");
}
private void OnLongPressCompleted(object sender, EventArgs e)
{
Console.WriteLine("Long press fired");
}
}
- Open the project
- Tap on Grid multiple times with minimal delay between taps - you will see Long press fired also
- Long press - you will see normal tap fired also
Link to public reproduction project repository
Environment
- .NET MAUI CommunityToolkit: 12.2.0
- OS: Microsoft Windows 10 Pro - 10.0.19045 Graditev 19045
- .NET MAUI: 9.0.110Anything else?
Sometimes if you do fast taps, then do a long press. You will get multiple long press fired in a short amount of time (less then the LongPressDuration).
Thank you for CoPilot who prepared everything.