Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: conditional on filter #229

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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