From 63fe796eace411404ebf5ef5d55b8b90172b736e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Monterisi?= Date: Sun, 29 Dec 2024 10:04:20 +0100 Subject: [PATCH] fix: focus search input on mount (#414) --- src/components/Search.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/Search.tsx b/src/components/Search.tsx index 9c5fd76..4ec41bc 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -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 ( <>