Focus file search input from ref (#3330)

This commit is contained in:
Neil
2026-05-29 14:50:05 -07:00
committed by GitHub
parent 6cfdb77b56
commit 351ad38f68
2 changed files with 9 additions and 5 deletions
@@ -106,9 +106,13 @@ export default function Search(): React.JSX.Element {
})
}, [cancelSeededInputSelectionFrame])
// Focus input on mount
useEffect(() => {
inputRef.current?.focus()
const setSearchInputRef = useCallback((el: HTMLInputElement | null): void => {
inputRef.current = el
// Why: focusing belongs to the input mount; the object ref still backs
// seeded-search selection and result keyboard handlers.
if (el) {
el.focus()
}
}, [])
// Cleanup debounce timer on unmount
@@ -324,7 +328,7 @@ export default function Search(): React.JSX.Element {
return (
<div className="flex flex-col h-full">
<SearchHeader
inputRef={inputRef}
inputRef={setSearchInputRef}
includeInputRef={includeInputRef}
excludeInputRef={excludeInputRef}
query={fileSearchQuery}
@@ -5,7 +5,7 @@ import { SearchFilters } from './SearchFilters'
import { ToggleButton } from './SearchResultItems'
type SearchHeaderProps = {
inputRef: React.RefObject<HTMLInputElement | null>
inputRef: React.Ref<HTMLInputElement>
includeInputRef: React.RefObject<HTMLInputElement | null>
excludeInputRef: React.RefObject<HTMLInputElement | null>
query: string