fix(dock): complete TabTearOffService migration and restore transactional integrity

This commit is contained in:
2026-03-28 17:23:49 +09:00
parent 0a0359ec06
commit 7ac9a66110
4 changed files with 8 additions and 12 deletions

View File

@@ -72,7 +72,6 @@ internal static class TabTearOffService
private static void RestoreSelection(object? container, object? selection) private static void RestoreSelection(object? container, object? selection)
{ {
if (selection == null) return;
if (container is DockPanelNode panel) panel.SelectedItem = selection; if (container is DockPanelNode panel) panel.SelectedItem = selection;
else if (container is TabView tabView) tabView.SelectedItem = selection; else if (container is TabView tabView) tabView.SelectedItem = selection;
} }

View File

@@ -436,8 +436,13 @@ public sealed partial class DockLayout : Control
{ {
var result = TabTearOffService.TryTearOffTab(sourceNode.Items, args.Item, (tab) => 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 // Raise event to let the host handle window creation
TabTornOff?.Invoke(this, new TabTornOffEventArgs(tab, sourceNode)); TabTornOff.Invoke(this, new TabTornOffEventArgs(tab, sourceNode));
}, sourceNode); }, sourceNode);
if (result.IsSuccess) if (result.IsSuccess)

View File

@@ -22,16 +22,7 @@ internal sealed partial class DockWindow : WindowEx
} }
private void OnTabTornOff(object? sender, TabTornOffEventArgs e) private void OnTabTornOff(object? sender, TabTornOffEventArgs e)
{
try
{ {
App.CreateAndShowDockWindow(e.TabContent); App.CreateAndShowDockWindow(e.TabContent);
} }
catch (Exception ex)
{
Logger.LogError(ex);
// The service handles rollback if this was called from TryTearOffTab
throw;
}
}
} }

View File

@@ -2,6 +2,7 @@ using Ghost.Core;
using Ghost.Editor.Core; using Ghost.Editor.Core;
using Ghost.Editor.Core.Contracts; using Ghost.Editor.Core.Contracts;
using Ghost.Editor.Core.Services; using Ghost.Editor.Core.Services;
using Ghost.Editor.Core.Controls.Internal.Docking;
using Ghost.Editor.View.Controls; using Ghost.Editor.View.Controls;
using Ghost.Editor.ViewModels.Windows; using Ghost.Editor.ViewModels.Windows;
using Windows.ApplicationModel; using Windows.ApplicationModel;