Skip to content

Commit

Permalink
showing title even if search value is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
TangoBeeAkto committed Dec 30, 2024
1 parent 43c4309 commit 2cc072e
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -86,7 +96,6 @@ function DropdownSearch(props) {
});
});
}else{
const defaultSliceValue = sliceMaxVal || 20
resultOptions = deselectedOptions.filter((option) =>
option[searchKey].match(filterRegex)
).slice(0, defaultSliceValue);
Expand Down

0 comments on commit 2cc072e

Please sign in to comment.