diff --git a/TablePro/Core/Services/Infrastructure/TabWindowController.swift b/TablePro/Core/Services/Infrastructure/TabWindowController.swift index 13bd9af2..a20ac665 100644 --- a/TablePro/Core/Services/Infrastructure/TabWindowController.swift +++ b/TablePro/Core/Services/Infrastructure/TabWindowController.swift @@ -236,6 +236,10 @@ internal final class TabWindowController: NSWindowController, NSWindowDelegate { Self.lifecycleLogger.debug( "[switch] windowDidResignKey seq=\(seq) controllerId=\(self.controllerId, privacy: .public)" ) + if let actions = coordinator.commandActions, + CommandActionsRegistry.shared.current === actions { + CommandActionsRegistry.shared.current = nil + } activity?.resignCurrent() coordinator.handleWindowDidResignKey() Self.lifecycleLogger.debug("[switch] windowDidResignKey seq=\(seq) total ms=\(Int(Date().timeIntervalSince(t0) * 1_000))") diff --git a/TablePro/TableProApp.swift b/TablePro/TableProApp.swift index 5aed2680..53ef3261 100644 --- a/TablePro/TableProApp.swift +++ b/TablePro/TableProApp.swift @@ -220,13 +220,8 @@ struct AppMenuCommands: Commands { Button(actions != nil ? "Close Tab" : "Close") { if let resolved = resolvedCloseTabActions { resolved.closeTab() - } else if let window = NSApp.keyWindow { - if window.identifier?.rawValue.hasPrefix("main") == true, - let coordinator = MainContentCoordinator.coordinator(forWindow: window) { - coordinator.commandActions?.closeTab() - } else { - window.performClose(nil) - } + } else { + NSApp.keyWindow?.performClose(nil) } } .optionalKeyboardShortcut(shortcut(for: .closeTab))