mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix: show search result only if input is more than one char
This commit is contained in:
@@ -53,7 +53,10 @@ export default function SearchBar({ searchList }: Props) {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSearchResults(fuse!.search!(inputVal!));
|
// Add search result only if
|
||||||
|
// input value is more than one character
|
||||||
|
let inputResult = inputVal.length > 1 ? fuse.search(inputVal) : [];
|
||||||
|
setSearchResults(inputResult);
|
||||||
|
|
||||||
// Update search string in URL
|
// Update search string in URL
|
||||||
if (inputVal.length > 0) {
|
if (inputVal.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user