Skip to content

Commit

Permalink
fix: show search result only if input is more than one char
Browse files Browse the repository at this point in the history
  • Loading branch information
satnaing committed Nov 4, 2022
1 parent 5eeea66 commit f7fb032
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export default function SearchBar({ searchList }: Props) {
}, []);

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
if (inputVal.length > 0) {
Expand Down

0 comments on commit f7fb032

Please sign in to comment.