Skip to content

Dragging onto a newly entered AllowDrop element raises DragEnter without DragOver, so the drop can be rejected #25754

Open

Description

@ajpinedam

Current behavior 🐛

When a drag moves onto an AllowDrop element it wasn't over before, Uno raises only DragEnter for that move:

So an ancestor that sets AcceptedOperation in DragOver doesn't run for that move. If the pointer is released before it moves again, the drop is rejected.

The visible case is a reorderable ListView whose item content sets AllowDrop="True". Drag an item onto the next item's content and release: DragItemsCompleted reports DropResult = None and nothing is reordered. The list's reorder handler is a DragOver handler, so it never sees that move.

Expected behavior 🎯

For one move, WinUI raises DragLeave on the elements the drag left, then DragEnter on the newly entered ones, then DragOver along the new path (CDragDropState::RaiseDragEnterEvents, InputServices.cpp:15015-15025).

The accepted operation is a single value for the whole drag. It is seeded into each event from the previous result, and reset only when the drag leaves the element that set it (DropOperationTarget.cpp:305-355, DragEventArgs.cpp:114-123).

This comes from reading the WinUI source. It wasn't run against WinUI.

How to reproduce it (as minimally and precisely as possible) 🔬

Runtime test on Skia Desktop. It uses UpdateLayoutOnUnloadedControl from Given_ListViewBase, which is what When_UpdateLayout_In_DragDropping uses.

[TestMethod]
[RunsOnUIThread]
public async Task When_Dropped_On_AllowDrop_Content_Of_Next_Item()
{
	var list = new ListView { AllowDrop = true, CanDragItems = true, CanReorderItems = true };
	for (var i = 0; i < 3; i++)
	{
		list.Items.Add(new UpdateLayoutOnUnloadedControl { Content = new TextBlock { AllowDrop = true, Height = 100, Text = i.ToString() } });
	}
	DataPackageOperation? result = null;
	list.DragItemsCompleted += (_, e) => result = e.DropResult;
	await UITestHelper.Load(list);

	var injector = InputInjector.TryCreate() ?? throw new InvalidOperationException();
	using var mouse = injector.GetMouse();
	var bounds = list.GetAbsoluteBoundsRect();
	mouse.MoveTo(bounds.GetCenter() with { Y = bounds.Y + 50 });
	await WindowHelper.WaitForIdle();
	mouse.Press();
	await WindowHelper.WaitForIdle();
	mouse.MoveTo(bounds.GetCenter() with { Y = bounds.Y + 100 }, 1);
	await WindowHelper.WaitForIdle();
	await UITestHelper.WaitForRender();
	mouse.MoveTo(bounds.GetCenter() with { Y = bounds.Y + 250 }, 1);
	await WindowHelper.WaitForIdle();
	mouse.Release();
	await WindowHelper.WaitForIdle();

	Assert.AreEqual(DataPackageOperation.Move, result); // fails: None
}

Events seen on the content TextBlocks:

Step Events
Move to y=100 tb1.DragEnter, then tb1.DragOver, where the list sets Move
Move to y=250 tb1.DragLeave, then tb2.DragEnter, and no DragOver
Release tb2.DragLeave, no Drop, and DropResult = None

Workaround 🛠️

Don't set AllowDrop on elements inside the items of a reorderable list.

Affected platforms 📱💻🖥️

Desktop (Windows). Verified on Win32; the code path is shared by every Skia head.

Uno.Sdk version (and other relevant versions) 📦

Uno master at faeb561, net11.0-desktop.

IDE version 🧑‍💻

Not IDE-related.

Anything else we need to know? 💬

Activity

  1. added
    kind/bug
    triage/untriaged
    area/drag-drop
    on Oct 27, 2026
  2. 1 remaining item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/drag-dropkind/bugtriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions