fix(dock): complete TabTearOffService migration and restore transactional integrity
This commit is contained in:
@@ -72,7 +72,6 @@ internal static class TabTearOffService
|
||||
|
||||
private static void RestoreSelection(object? container, object? selection)
|
||||
{
|
||||
if (selection == null) return;
|
||||
if (container is DockPanelNode panel) panel.SelectedItem = selection;
|
||||
else if (container is TabView tabView) tabView.SelectedItem = selection;
|
||||
}
|
||||
|
||||
@@ -436,8 +436,13 @@ public sealed partial class DockLayout : Control
|
||||
{
|
||||
var result = TabTearOffService.TryTearOffTab(sourceNode.Items, args.Item, (tab) =>
|
||||
{
|
||||
if (TabTornOff == null)
|
||||
{
|
||||
throw new InvalidOperationException("No tear-off handler attached.");
|
||||
}
|
||||
|
||||
// Raise event to let the host handle window creation
|
||||
TabTornOff?.Invoke(this, new TabTornOffEventArgs(tab, sourceNode));
|
||||
TabTornOff.Invoke(this, new TabTornOffEventArgs(tab, sourceNode));
|
||||
}, sourceNode);
|
||||
|
||||
if (result.IsSuccess)
|
||||
|
||||
@@ -22,16 +22,7 @@ internal sealed partial class DockWindow : WindowEx
|
||||
}
|
||||
|
||||
private void OnTabTornOff(object? sender, TabTornOffEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
App.CreateAndShowDockWindow(e.TabContent);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex);
|
||||
// The service handles rollback if this was called from TryTearOffTab
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Ghost.Core;
|
||||
using Ghost.Editor.Core;
|
||||
using Ghost.Editor.Core.Contracts;
|
||||
using Ghost.Editor.Core.Services;
|
||||
using Ghost.Editor.Core.Controls.Internal.Docking;
|
||||
using Ghost.Editor.View.Controls;
|
||||
using Ghost.Editor.ViewModels.Windows;
|
||||
using Windows.ApplicationModel;
|
||||
|
||||
Reference in New Issue
Block a user