Skip to content

Commit

Permalink
fix: focus search input on mount (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebSept authored Dec 29, 2024
1 parent 397e321 commit 63fe796
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ export default function SearchBar({ searchList }: Props) {
}
}, [inputVal]);

useEffect(() => {
// focus on text input when search bar is displayed
if (inputRef.current) {
inputRef.current.focus();
}
}, [inputVal]);

return (
<>
<label className="relative block">
Expand Down

0 comments on commit 63fe796

Please sign in to comment.