From 9b4d1948be76173f48fde7052a02d5af660d6f98 Mon Sep 17 00:00:00 2001 From: Sat Naing Date: Fri, 16 Sep 2022 09:08:13 +0630 Subject: [PATCH 1/4] Update threshold to 4.0 --- src/components/Search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Search.tsx b/src/components/Search.tsx index 4b7d164..cf2fc6e 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -36,7 +36,7 @@ export default function SearchBar({ searchList }: Props) { const fuse = new Fuse(searchList, { keys: ["title", "description"], includeMatches: true, - threshold: 0.3, + threshold: 0.4, }); useEffect(() => { From 7b024d2b96eb6e396de70511e17f8ce1f8077c8e Mon Sep 17 00:00:00 2001 From: Sat Naing Date: Fri, 16 Sep 2022 13:38:15 +0630 Subject: [PATCH 2/4] Update threshold for search to 0.5 --- src/components/Search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Search.tsx b/src/components/Search.tsx index cf2fc6e..2bdbf8e 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -36,7 +36,7 @@ export default function SearchBar({ searchList }: Props) { const fuse = new Fuse(searchList, { keys: ["title", "description"], includeMatches: true, - threshold: 0.4, + threshold: 0.5, }); useEffect(() => { From d1fa01567d8e8de963d66a509eab36d197b4efc6 Mon Sep 17 00:00:00 2001 From: Sat Naing Date: Fri, 16 Sep 2022 13:41:41 +0630 Subject: [PATCH 3/4] Update min character match for search to 2 --- src/components/Search.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Search.tsx b/src/components/Search.tsx index 2bdbf8e..92096cb 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -36,6 +36,7 @@ export default function SearchBar({ searchList }: Props) { const fuse = new Fuse(searchList, { keys: ["title", "description"], includeMatches: true, + minMatchCharLength: 2, threshold: 0.5, }); From 2fa9d6ee27254d9aaddbb5d1a64ad594a1876552 Mon Sep 17 00:00:00 2001 From: Sat Naing Date: Fri, 16 Sep 2022 13:42:34 +0630 Subject: [PATCH 4/4] Display found result text when input char is above 2 --- src/components/Search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Search.tsx b/src/components/Search.tsx index 92096cb..3f05ae2 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -67,7 +67,7 @@ export default function SearchBar({ searchList }: Props) { /> - {searchResults && searchResults.length > 0 && ( + {inputVal.length > 1 && (
Found {searchResults?.length} {searchResults?.length && searchResults?.length > 1