From 2cc072e4518459f961d5523db804bd64615a0c10 Mon Sep 17 00:00:00 2001 From: Umesh Kumar <166806589+TangoBeeAkto@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:03:57 +0530 Subject: [PATCH] showing title even if search value is empty --- .../dashboard/components/shared/DropdownSearch.jsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/DropdownSearch.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/DropdownSearch.jsx index adf632e989..1f5809c392 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/DropdownSearch.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/shared/DropdownSearch.jsx @@ -65,9 +65,19 @@ function DropdownSearch(props) { setLoading(true); } + const defaultSliceValue = sliceMaxVal || 20 + setTimeout(() => { if (value === '' && selectedOptions.length === 0) { - setOptions(deselectedOptions); + const options = deselectedOptions.slice(0, defaultSliceValue); + const title = options.length >= defaultSliceValue + ? `Showing ${options.length} result${func.addPlurality(options.length)} only. (type more to refine results)` + : "Showing all results"; + const nestedOptions = [{ + title: title, + options: options + }] + setOptions(nestedOptions); setLoading(false); return; } @@ -86,7 +96,6 @@ function DropdownSearch(props) { }); }); }else{ - const defaultSliceValue = sliceMaxVal || 20 resultOptions = deselectedOptions.filter((option) => option[searchKey].match(filterRegex) ).slice(0, defaultSliceValue);