-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] - Handle Dynamic Updates for CanDrag and AllowDrop in Drag and Drop Gesture #27845
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
PureWeen
merged 6 commits into
dotnet:inflight/current
from
prakashKannanSf3972:fix_12726
Apr 18, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6b9635a
Fixed-Drag-And-Drop-RunTime
prakashKannanSf3972 0abc396
Modified-Test
prakashKannanSf3972 d6d22d4
Reverted-test
prakashKannanSf3972 fbe12bb
Modified-Code
prakashKannanSf3972 7a632cb
Reverted-Unwanted-Changes
prakashKannanSf3972 5e37143
Modified.
prakashKannanSf3972 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
|
|
||
| [Issue(IssueTracker.Github, 12726, "Drag and Drop Gesture Fails on Runtime Changes of CanDrag and AllowDrop in Windows", | ||
| PlatformAffected.UWP)] | ||
| public class Issue12726 : TestContentPage | ||
| { | ||
| protected override void Init() | ||
| { | ||
| Label dragResult = new Label(); | ||
| Label dropResult = new Label(); | ||
|
|
||
| DragGestureRecognizer dragGestureRecognizer = new DragGestureRecognizer { CanDrag = false }; | ||
| Label dragBox = new Label | ||
| { | ||
| HeightRequest = 200, | ||
| WidthRequest = 200, | ||
| BackgroundColor = Colors.Purple, | ||
| GestureRecognizers = { dragGestureRecognizer }, | ||
| AutomationId = "DragElement" | ||
| }; | ||
| dragGestureRecognizer.DragStarting += (_, __) => dragResult.Text = "DragEventTriggered"; | ||
|
|
||
| DropGestureRecognizer dropGestureRecognizer = new DropGestureRecognizer { AllowDrop = false }; | ||
| Label dropBox = new Label | ||
| { | ||
| HeightRequest = 200, | ||
| WidthRequest = 200, | ||
| BackgroundColor = Colors.Pink, | ||
| GestureRecognizers = { dropGestureRecognizer }, | ||
| AutomationId = "DropTarget" | ||
| }; | ||
| dropGestureRecognizer.Drop += (_, __) => dropResult.Text = "DropEventTriggered"; | ||
|
|
||
| Button button = new Button | ||
| { | ||
| Text = "Enable Drag and Drop", | ||
| AutomationId = "EnableDragAndDrop" | ||
| }; | ||
|
|
||
| button.Clicked += (_, __) => | ||
| { | ||
| dragGestureRecognizer.CanDrag = true; | ||
| dropGestureRecognizer.AllowDrop = true; | ||
| }; | ||
|
|
||
| Content = new StackLayout | ||
| { | ||
| Spacing = 5, | ||
| Children = | ||
| { | ||
| dragBox, | ||
| dropBox, | ||
| button, | ||
| dragResult, | ||
| dropResult | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue12726.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,25 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue12726 : _IssuesUITest | ||
| { | ||
| public Issue12726(TestDevice testDevice) : base(testDevice) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Drag and Drop Gesture Fails on Runtime Changes of CanDrag and AllowDrop in Windows"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.DragAndDrop)] | ||
| public void DragAndDropShouldWorkRunTime() | ||
| { | ||
| App.WaitForElement("EnableDragAndDrop"); | ||
| App.Tap("EnableDragAndDrop"); | ||
| App.DragAndDrop("DragElement", "DropTarget"); | ||
| App.WaitForElement("DragEventTriggered"); | ||
| } | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is failing on Windows:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsuarezruiz,
Thank you for pointing this out! The failure appears to be due to the programmatic drop operation not functioning correctly on the Windows platform in the CI environment, despite working on local machines. I have modified the test accordingly, and it should pass in the next CI run.