fix(dock): add drag payload validation and ensure unconditional state cleanup

This commit is contained in:
2026-03-28 16:47:08 +09:00
parent e80266f2bc
commit 5ceb7c11ed

View File

@@ -386,7 +386,8 @@ public sealed partial class DockLayout : Control
{ {
if (_dropTargetOverlay != null) _dropTargetOverlay.Visibility = Visibility.Collapsed; if (_dropTargetOverlay != null) _dropTargetOverlay.Visibility = Visibility.Collapsed;
if (_draggedItem == null || _sourceNode == null || !(sender is FrameworkElement targetElement) || !(targetElement.Tag is DockPanelNode targetNode)) if (!e.DataView.Properties.ContainsKey(DRAG_PROPERTY_DOCK_TAB) ||
_draggedItem == null || _sourceNode == null || !(sender is FrameworkElement targetElement) || !(targetElement.Tag is DockPanelNode targetNode))
{ {
ClearDragOperationState(); ClearDragOperationState();
return; return;
@@ -421,19 +422,24 @@ public sealed partial class DockLayout : Control
private void TabView_TabDroppedOutside(Microsoft.UI.Xaml.Controls.TabView sender, Microsoft.UI.Xaml.Controls.TabViewTabDroppedOutsideEventArgs args) private void TabView_TabDroppedOutside(Microsoft.UI.Xaml.Controls.TabView sender, Microsoft.UI.Xaml.Controls.TabViewTabDroppedOutsideEventArgs args)
{ {
if (_sourceNode != null && _draggedItem != null) try
{ {
var result = TabTearOffService.TryTearOffTab(_sourceNode.Items, _draggedItem, _sourceNode); if (_sourceNode != null && _draggedItem != null)
if (result.IsSuccess)
{ {
DockMutationEngine.CleanupEmptyNodes(_sourceNode); var result = TabTearOffService.TryTearOffTab(_sourceNode.Items, _draggedItem, _sourceNode);
}
else
{
Logger.LogWarning($"Tab tear-off failed: {result.Message}");
}
if (result.IsSuccess)
{
DockMutationEngine.CleanupEmptyNodes(_sourceNode);
}
else
{
Logger.LogWarning($"Tab tear-off failed: {result.Message}");
}
}
}
finally
{
ClearDragOperationState(); ClearDragOperationState();
} }
} }