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.
pull/12338/head
Lukas 2026-04-19 20:53:19 +02:00
parent b0f8276658
commit 366c34831a
No known key found for this signature in database
GPG Key ID: 1944A0A77B561220
1 changed files with 6 additions and 2 deletions

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