CommunityToolkit / CommunityToolkit/Maui

[BUG] TouchBehavior: Tap and LongPress conflict (Tap fires after LongPress, or LongPress misfires as Tap)

Open
#2,894 5 comments 0 reactions 0 assignees View on GitHub
bug unverified
Dominant language
C#
Stars
2.7k
Forks
500
Avg merge
2d 14h
Merged PRs (30d)
7

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Did you read the "Reporting a bug" section on Contributing file?

- [x] 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

```







```

**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");
}
}
```

1. Open the project
2. Tap on Grid multiple times with minimal delay between taps - you will see Long press fired also
3. Long press - you will see normal tap fired also

### Link to public reproduction project repository

https://github.com/rokmeglic71/Tap-and-LongPress-conflict-Tap-fires-after-LongPress-or-LongPress-misfires-as-Tap-

### Environment

```markdown
- .NET MAUI CommunityToolkit: 12.2.0
- OS: Microsoft Windows 10 Pro - 10.0.19045 Graditev 19045
- .NET MAUI: 9.0.110
```

### Anything 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.

Contributor guide

Open the contributing guide

Research direction

Start with the provided MainPage.xaml and MainPage.xaml.cs reproduction, then trace TouchBehavior's TouchGestureCompleted and LongPressCompleted handling. Run the reproduction with quick taps and long presses, and confirm that a quick tap triggers only the tap handler while a long press triggers only the long-press handler, including after repeated taps.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.