fix: clear picker focus frames from refs

This commit is contained in:
Neil
2026-05-29 23:47:31 -07:00
parent 2982659d2c
commit d6329fde6e
5 changed files with 44 additions and 10 deletions
@@ -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({
>
<Command shouldFilter={false} value={commandValue} onValueChange={setCommandValue}>
<CommandInput
ref={inputRef}
ref={setInputNode}
placeholder="Search agents..."
value={query}
onValueChange={setQuery}
@@ -77,7 +77,16 @@ export function CreateFromPicker({
}
}, [])
React.useEffect(() => 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({
>
<Command>
<CommandInput
ref={inputRef}
ref={setInputNode}
value={query}
onValueChange={setQuery}
placeholder="Search repo branches..."
@@ -35,7 +35,16 @@ export function WorkspaceCombobox({
}
}, [])
React.useEffect(() => 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({
}}
>
<Command>
<CommandInput ref={inputRef} placeholder="Search workspaces..." />
<CommandInput ref={setInputNode} placeholder="Search workspaces..." />
<CommandList className="max-h-72">
<CommandEmpty>No workspaces found.</CommandEmpty>
{worktrees.map((worktree) => (
@@ -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({
>
<Command shouldFilter={false} value={commandValue} onValueChange={setCommandValue}>
<CommandInput
ref={inputRef}
ref={setInputNode}
placeholder="Search projects/folders..."
value={query}
onValueChange={setQuery}
@@ -704,8 +704,6 @@ export function ResourceUsageStatusSegment({
popoverBodyFocusFrameRef.current = null
}, [])
useEffect(() => cancelPopoverBodyFocusFrame, [cancelPopoverBodyFocusFrame])
const setPopoverBodyNode = useCallback(
(node: HTMLDivElement | null): void => {
// Why: the queued post-kill focus is only valid while the popover body exists.