Skip to content

[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
merged 6 commits into from
Apr 18, 2025

Conversation

prakashKannanSf3972
Copy link
Contributor

Issue Details

Dynamically changing the CanDrag or AllowDrop property does not enable the expected drag-and-drop functionality when initially set to false. As a result, components cannot be made draggable or droppable by updating these properties at runtime.

Root Cause

Event subscriptions were only set up during initialization. Changing CanDrag or AllowDrop dynamically did not trigger a re-subscription, preventing the component from responding to both drag and drop events.

Description of Change

Added PropertyChanged event handling for DragGestureRecognizer and DropGestureRecognizer to ensure that drag-and-drop event subscriptions are updated dynamically when the properties change.

Issues Fixed

Fixes #12726

Validated the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Output

Before After
Before-Fix.2.mp4
After-Fix.2.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 17, 2025
Copy link
Contributor

Hey there @prakashKannanSf3972! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Feb 17, 2025
@jsuarezruiz
Copy link
Contributor

jsuarezruiz commented Feb 17, 2025

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).


[Test]
[Category(UITestCategories.DragAndDrop)]
public void DragAndDropShouldWorkRunTime()
Copy link
Contributor

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:

at UITest.Appium.HelperExtensions.Wait(Func`1 query, Func`2 satisfactory, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2352
   at UITest.Appium.HelperExtensions.WaitForAtLeastOne(Func`1 query, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 2367
   at UITest.Appium.HelperExtensions.WaitForElement(IApp app, String marked, String timeoutMessage, Nullable`1 timeout, Nullable`1 retryFrequency, Nullable`1 postTimeout) in /_/src/TestUtils/src/UITest.Appium/HelperExtensions.cs:line 663
   at Microsoft.Maui.TestCases.Tests.Issues.Issue12726.DragAndDropShouldWorkRunTime() in /_/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue12726.cs:line 23
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Copy link
Contributor Author

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.

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@prakashKannanSf3972 prakashKannanSf3972 marked this pull request as ready for review February 20, 2025 11:02
@prakashKannanSf3972 prakashKannanSf3972 requested a review from a team as a code owner February 20, 2025 11:02
@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz
Copy link
Contributor

/rebase

@jsuarezruiz
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current April 18, 2025 09:34
@PureWeen PureWeen merged commit f1d8b2f into dotnet:inflight/current Apr 18, 2025
128 checks passed
PureWeen pushed a commit that referenced this pull request Apr 23, 2025
…and Drop Gesture (#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
prakashKannanSf3972 added a commit to prakashKannanSf3972/maui that referenced this pull request Apr 24, 2025
…and Drop Gesture (dotnet#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
NanthiniMahalingam pushed a commit to NanthiniMahalingam/maui that referenced this pull request Apr 24, 2025
…and Drop Gesture (dotnet#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
prakashKannanSf3972 added a commit to prakashKannanSf3972/maui that referenced this pull request Apr 25, 2025
…and Drop Gesture (dotnet#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
prakashKannanSf3972 added a commit to prakashKannanSf3972/maui that referenced this pull request Apr 28, 2025
…and Drop Gesture (dotnet#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
github-actions bot pushed a commit that referenced this pull request Apr 28, 2025
…and Drop Gesture (#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
anandhan-rajagopal pushed a commit to anandhan-rajagopal/maui that referenced this pull request May 2, 2025
…and Drop Gesture (dotnet#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
anandhan-rajagopal pushed a commit to anandhan-rajagopal/maui that referenced this pull request May 2, 2025
…and Drop Gesture (dotnet#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
PureWeen pushed a commit that referenced this pull request May 2, 2025
…and Drop Gesture (#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request May 9, 2025
…and Drop Gesture (dotnet#27845)

* Fixed-Drag-And-Drop-RunTime

* Modified-Test

* Reverted-test

* Modified-Code

* Reverted-Unwanted-Changes

* Modified.
@github-actions github-actions bot locked and limited conversation to collaborators May 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-gestures Gesture types community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DragGestureRecognizer CanDrag binding not working properly
3 participants