fix(dock): complete tear-off flow and add rollback on failure
This commit is contained in:
@@ -306,20 +306,23 @@ public sealed partial class DockLayout : Control
|
||||
{
|
||||
DockMutationEngine.CleanupEmptyNodes(_sourceNode);
|
||||
|
||||
// Raise event to let the host handle window creation
|
||||
TabTornOff?.Invoke(this, new TabTornOffEventArgs(_draggedItem));
|
||||
try
|
||||
{
|
||||
// Raise event to let the host handle window creation
|
||||
TabTornOff?.Invoke(this, new TabTornOffEventArgs(_draggedItem));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Rollback: Re-insert the item if the tear-off handler fails
|
||||
_sourceNode.Items.Add(_draggedItem);
|
||||
Logger.LogError($"Failed to tear off tab: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
ClearDragOperationState();
|
||||
}
|
||||
}
|
||||
|
||||
public class TabTornOffEventArgs : EventArgs
|
||||
{
|
||||
public object TabContent { get; }
|
||||
public TabTornOffEventArgs(object tabContent) => TabContent = tabContent;
|
||||
}
|
||||
|
||||
private object? _draggedItem;
|
||||
private DockPanelNode? _sourceNode;
|
||||
private DockPosition _currentDropPosition = DockPosition.None;
|
||||
|
||||
Reference in New Issue
Block a user