From d6329fde6e1417b7c7a039bfca5802dcc5053a5e Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 29 May 2026 23:47:31 -0700 Subject: [PATCH] fix: clear picker focus frames from refs --- src/renderer/src/components/agent/AgentCombobox.tsx | 13 +++++++++++-- .../src/components/automations/CreateFromPicker.tsx | 13 +++++++++++-- .../components/automations/WorkspaceCombobox.tsx | 13 +++++++++++-- src/renderer/src/components/repo/RepoCombobox.tsx | 13 +++++++++++-- .../status-bar/ResourceUsageStatusSegment.tsx | 2 -- 5 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/renderer/src/components/agent/AgentCombobox.tsx b/src/renderer/src/components/agent/AgentCombobox.tsx index c33a9a37023..03f2ec6a6b1 100644 --- a/src/renderer/src/components/agent/AgentCombobox.tsx +++ b/src/renderer/src/components/agent/AgentCombobox.tsx @@ -161,7 +161,16 @@ export default function AgentCombobox({ } }, []) - React.useEffect(() => cancelFocusFrame, [cancelFocusFrame]) + const setInputNode = useCallback( + (node: HTMLInputElement | null): void => { + // Why: queued popover focus is only valid while the command input exists. + if (!node) { + cancelFocusFrame() + } + inputRef.current = node + }, + [cancelFocusFrame] + ) const focusSearchInput = useCallback(() => { cancelFocusFrame() @@ -292,7 +301,7 @@ export default function AgentCombobox({ > cancelFocusFrame, [cancelFocusFrame]) + const setInputNode = React.useCallback( + (node: HTMLInputElement | null): void => { + // Why: queued popover focus is only valid while the command input exists. + if (!node) { + cancelFocusFrame() + } + inputRef.current = node + }, + [cancelFocusFrame] + ) const focusSearchInput = React.useCallback(() => { cancelFocusFrame() @@ -188,7 +197,7 @@ export function CreateFromPicker({ > cancelFocusFrame, [cancelFocusFrame]) + const setInputNode = React.useCallback( + (node: HTMLInputElement | null): void => { + // Why: queued popover focus is only valid while the command input exists. + if (!node) { + cancelFocusFrame() + } + inputRef.current = node + }, + [cancelFocusFrame] + ) const focusSearchInput = React.useCallback(() => { cancelFocusFrame() @@ -80,7 +89,7 @@ export function WorkspaceCombobox({ }} > - + No workspaces found. {worktrees.map((worktree) => ( diff --git a/src/renderer/src/components/repo/RepoCombobox.tsx b/src/renderer/src/components/repo/RepoCombobox.tsx index 5ba668853df..54523410d3a 100644 --- a/src/renderer/src/components/repo/RepoCombobox.tsx +++ b/src/renderer/src/components/repo/RepoCombobox.tsx @@ -63,7 +63,16 @@ export default function RepoCombobox({ } }, []) - React.useEffect(() => cancelFocusFrame, [cancelFocusFrame]) + const setInputNode = useCallback( + (node: HTMLInputElement | null): void => { + // Why: queued popover focus is only valid while the command input exists. + if (!node) { + cancelFocusFrame() + } + inputRef.current = node + }, + [cancelFocusFrame] + ) const focusSearchInput = useCallback(() => { cancelFocusFrame() @@ -208,7 +217,7 @@ export default function RepoCombobox({ > cancelPopoverBodyFocusFrame, [cancelPopoverBodyFocusFrame]) - const setPopoverBodyNode = useCallback( (node: HTMLDivElement | null): void => { // Why: the queued post-kill focus is only valid while the popover body exists.