From 366c34831a39651b196f216f1e9fd651568b60b8 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Sun, 19 Apr 2026 20:53:19 +0200 Subject: [PATCH] macOS: fix first responder after dragging a non-focused surface This fixes a bug: after dragging a non-focused surface from window A to window B **quickly without making B the key window**, the focused surface in window A is not receiving `keyDown` events. --- .../Features/Terminal/BaseTerminalController.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index f5b500b70..9454b1f86 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -458,8 +458,12 @@ class BaseTerminalController: NSWindowController, replaceSurfaceTree( surfaceTree.removing(node), - moveFocusTo: nextFocus, - moveFocusFrom: focusedSurface, + // When a non-focused surface is removed and this window stays as the key window, + // we should refocus the `focusedSurface` to make sure the window's firstResponder remains as it is. + // + // This is a weird workaround, since `resignFirstResponder` wasn't called on `focusedSurface` after drag, + // but the first responder became the window itself. + moveFocusTo: nextFocus ?? focusedSurface, undoAction: "Close Terminal" ) }