Skip to content

Commit 63fe796

Browse files
authored
fix: focus search input on mount (#414)
1 parent 397e321 commit 63fe796

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/components/Search.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ export default function SearchBar({ searchList }: Props) {
7373
}
7474
}, [inputVal]);
7575

76+
useEffect(() => {
77+
// focus on text input when search bar is displayed
78+
if (inputRef.current) {
79+
inputRef.current.focus();
80+
}
81+
}, [inputVal]);
82+
7683
return (
7784
<>
7885
<label className="relative block">

0 commit comments

Comments
 (0)