Skip to content

Commit 366c348

Browse files
committed
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.
1 parent b0f8276 commit 366c348

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

macos/Sources/Features/Terminal/BaseTerminalController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,12 @@ class BaseTerminalController: NSWindowController,
458458

459459
replaceSurfaceTree(
460460
surfaceTree.removing(node),
461-
moveFocusTo: nextFocus,
462-
moveFocusFrom: focusedSurface,
461+
// When a non-focused surface is removed and this window stays as the key window,
462+
// we should refocus the `focusedSurface` to make sure the window's firstResponder remains as it is.
463+
//
464+
// This is a weird workaround, since `resignFirstResponder` wasn't called on `focusedSurface` after drag,
465+
// but the first responder became the window itself.
466+
moveFocusTo: nextFocus ?? focusedSurface,
463467
undoAction: "Close Terminal"
464468
)
465469
}

0 commit comments

Comments
 (0)