fix(terminal): don't steal focus from modal dialog inputs (#11745)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aed87407af
commit
a78fff991b
1 file changed
+16
-1
@@ -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<void> {
|
||||
|
||||
Reference in new issue
Block a user