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.
This commit is contained in:
Lukas
2026-04-19 20:53:19 +02:00
parent b0f8276658
commit 366c34831a

View File

@@ -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"
)
}