From a78fff991b891cbcf4c2cc6ba172c81ec92151dc Mon Sep 17 00:00:00 2001 From: siparker Date: Tue, 6 Oct 2026 21:08:35 +0100 Subject: [PATCH] fix(terminal): don't steal focus from modal dialog inputs (#11745) Co-authored-by: Claude Opus 5.5 --- tabby-terminal/src/frontends/xtermFrontend.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tabby-terminal/src/frontends/xtermFrontend.ts b/tabby-terminal/src/frontends/xtermFrontend.ts index 6849daf25..2404e600e 100644 --- a/tabby-terminal/src/frontends/xtermFrontend.ts +++ b/tabby-terminal/src/frontends/xtermFrontend.ts @@ -583,7 +583,22 @@ export class XTermFrontend extends Frontend { } focus (): void { - setTimeout(() => this.xterm.focus()) + setTimeout(() => { + // Don't steal focus from modal dialogs (e.g. the SSH password prompt) + // or the tab's own overlay inputs - the deferred focus from a window + // focus event would otherwise land right after the user clicks into one + const active = document.activeElement + const tabHost = this.element?.parentElement + if ( + active instanceof HTMLElement + && active !== this.xterm.textarea + && active.matches('input, textarea, select') + && ((tabHost?.contains(active) ?? false) || active.closest('ngb-modal-window') !== null) + ) { + return + } + this.xterm.focus() + }) } async write (data: string): Promise {