Skip to content

Commit

Permalink
Merge pull request #229 from mazipan/mazipan/fix-conditional
Browse files Browse the repository at this point in the history
fix: conditional on filter
  • Loading branch information
ekamuktia authored Jul 20, 2021
2 parents f3925bf + 7f8f13b commit 013f372
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions components/search-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,22 @@ export function SearchForm({
<option value="">Semua</option>
{buckets.map((bucket: any, bIdx: number) => {
if (bucket.key) {
if (checkDocSize && bucket.doc_count > 0) {
if (checkDocSize) {
if (bucket.doc_count > 0) {
return (
<option
key={`option-${key}-${bIdx + 1}`}
value={bucket.key}
>
{bucket.key}
</option>
);
}
// Do not print, when doc_count = 0 and checkDocSize set to true
return null;
} else {
// FAQ page doesn't check the doc_count
// just pass checkDocSize props to false
return (
<option
key={`option-${key}-${bIdx + 1}`}
Expand All @@ -175,16 +190,6 @@ export function SearchForm({
</option>
);
}

// FAQ page doesn't check the doc_count
return (
<option
key={`option-${key}-${bIdx + 1}`}
value={bucket.key}
>
{bucket.key}
</option>
);
}
return null;
})}
Expand Down

0 comments on commit 013f372

Please sign in to comment.