From 34ebcbf8a0b7240bd4ace08def5e0b9cfcec2707 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 18 Apr 2026 23:07:08 -0700 Subject: [PATCH] fix: restore terminal focus after context menu copy/paste (#819) --- .../terminal-pane/use-terminal-pane-context-menu.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts b/src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts index 2c9c448e421..c5dbc1befa0 100644 --- a/src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts +++ b/src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts @@ -76,6 +76,11 @@ export function useTerminalPaneContextMenu({ if (selection) { await window.api.ui.writeClipboardText(selection) } + // Why: Radix returns focus to the menu trigger (the pane container) on + // close, but xterm.js only accepts input when its own helper textarea is + // focused. Without this, the user has to click the pane again before + // typing works (see #592). + pane.terminal.focus() } const onPaste = async (): Promise => { @@ -86,6 +91,7 @@ export function useTerminalPaneContextMenu({ const text = await window.api.ui.readClipboardText() if (text) { pane.terminal.paste(text) + pane.terminal.focus() return } // Why: clipboard has no text — check for an image (e.g. screenshot). @@ -95,6 +101,11 @@ export function useTerminalPaneContextMenu({ if (filePath) { pane.terminal.paste(filePath) } + // Why: Radix returns focus to the menu trigger (the pane container) on + // close, but xterm.js only accepts input when its own helper textarea is + // focused. Without this, the user has to click the pane again before + // typing works (see #592). + pane.terminal.focus() } const onSplitRight = (): void => {