-
Notifications
You must be signed in to change notification settings - Fork 2k
[Android] Fix DragGestureRecognizer DragStarting Command/Event fired prematurely #35778
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
Merged
kubaflo
merged 7 commits into
dotnet:inflight/current
from
HarishwaranVijayakumar:fix-35752
Jun 8, 2026
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e904e90
ci: skip provision AVD creation in ci-copilot.yml (inline script owns…
PureWeen 45e2a4d
Stop PR Review Queue workflow from running on forks and @-pinging PR …
PureWeen 1221e4d
[ci] Set __PWSH_LOGIN_CHECKED to avoid macOS pwsh 'procargs failed' s…
PureWeen fbbc977
Add fix
HarishwaranVijayakumar a062659
Update test and modify fix
HarishwaranVijayakumar b7372b3
Remove space
HarishwaranVijayakumar d19b1d9
Update shared file
HarishwaranVijayakumar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 35752, "Android DragGestureRecognizer DragStarting fires prematurely on tap", PlatformAffected.Android)] | ||
| public class Issue35752 : TestContentPage | ||
| { | ||
| protected override void Init() | ||
| { | ||
| var statusLabel = new Label | ||
| { | ||
| Text = "Ready", | ||
| AutomationId = "StatusLabel" | ||
| }; | ||
|
|
||
| var dragCountLabel = new Label | ||
| { | ||
| Text = "0", | ||
| AutomationId = "DragStartCount" | ||
| }; | ||
|
|
||
| int dragStartCount = 0; | ||
|
|
||
| var dragRecognizer = new DragGestureRecognizer(); | ||
| dragRecognizer.DragStarting += (s, e) => | ||
| { | ||
| dragStartCount++; | ||
| dragCountLabel.Text = dragStartCount.ToString(); | ||
| statusLabel.Text = "DragStarting fired"; | ||
| }; | ||
|
|
||
| var dragBox = new Label | ||
| { | ||
| HeightRequest = 100, | ||
| WidthRequest = 200, | ||
| BackgroundColor = Colors.Blue, | ||
| AutomationId = "DragBox", | ||
| Text = "Drag Me", | ||
| TextColor = Colors.White, | ||
| HorizontalTextAlignment = TextAlignment.Center, | ||
| VerticalTextAlignment = TextAlignment.Center, | ||
| GestureRecognizers = { dragRecognizer } | ||
| }; | ||
|
|
||
| var dropRecognizer = new DropGestureRecognizer(); | ||
| var dropBox = new Label | ||
| { | ||
| HeightRequest = 100, | ||
| WidthRequest = 200, | ||
| BackgroundColor = Colors.Green, | ||
| AutomationId = "DropBox", | ||
| Text = "Drop Here", | ||
| TextColor = Colors.White, | ||
| HorizontalTextAlignment = TextAlignment.Center, | ||
| VerticalTextAlignment = TextAlignment.Center, | ||
| GestureRecognizers = { dropRecognizer } | ||
| }; | ||
|
|
||
| var instructions = new Label | ||
| { | ||
| Text = "Quick tap the blue box - DragStarting should NOT fire. " + | ||
| "Long press or drag it - DragStarting SHOULD fire.", | ||
| AutomationId = "TestLoaded" | ||
| }; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Spacing = 20, | ||
| Padding = new Thickness(20), | ||
| Children = | ||
| { | ||
| instructions, | ||
| dragBox, | ||
| dropBox, | ||
| new Label { Text = "Status:" }, | ||
| statusLabel, | ||
| new Label { Text = "DragStart count:" }, | ||
| dragCountLabel | ||
| } | ||
| }; | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue35752.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue35752 : _IssuesUITest | ||
| { | ||
| public override string Issue => "Android DragGestureRecognizer DragStarting fires prematurely on tap"; | ||
|
|
||
| public Issue35752(TestDevice device) | ||
| : base(device) | ||
| { } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Gestures)] | ||
| public void DragStartingShouldNotFireOnTapButShouldFireOnDrag() | ||
| { | ||
| App.WaitForElement("TestLoaded"); | ||
|
|
||
| App.Tap("DragBox"); | ||
|
|
||
| Thread.Sleep(400); | ||
|
HarishwaranVijayakumar marked this conversation as resolved.
Outdated
HarishwaranVijayakumar marked this conversation as resolved.
Outdated
|
||
|
|
||
| var dragCount = App.WaitForElement("DragStartCount").GetText(); | ||
| Assert.That(dragCount, Is.EqualTo("0"), | ||
| "DragStarting should not fire on a quick tap"); | ||
|
|
||
| // Initiate drag - DragStarting SHOULD fire | ||
| App.DragAndDrop("DragBox", "DropBox"); | ||
|
|
||
| dragCount = App.WaitForElement("DragStartCount").GetText(); | ||
| Assert.That(dragCount, Is.EqualTo("1"), | ||
| "DragStarting should fire when drag is initiated"); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.