mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
fix: focus search input on mount (#414)
This commit is contained in:
committed by
GitHub
parent
397e3211d7
commit
63fe796eac
@@ -73,6 +73,13 @@ export default function SearchBar({ searchList }: Props) {
|
|||||||
}
|
}
|
||||||
}, [inputVal]);
|
}, [inputVal]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// focus on text input when search bar is displayed
|
||||||
|
if (inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
}
|
||||||
|
}, [inputVal]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<label className="relative block">
|
<label className="relative block">
|
||||||
|
|||||||
Reference in New Issue
Block a user