Skip to content

Commit 7ac9c13

Browse files
realmarcinclaude
andcommitted
Fix boolean facet filtering in browser
Fixed bug where boolean facets (High Metal Content, High REE Content) showed correct counts but returned no results when selected. Issue: HTML data attributes convert all values to strings, so the boolean value 'true' in the data was being compared to the string "true" from the checkbox filter, causing comparison to fail. Solution: Added type-aware filtering logic that converts boolean values to strings before comparison when the facet type is 'boolean'. Now users can successfully filter by: - High Metal Content: true (960 media) - High REE Content: true (913 media) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 74ad340 commit 7ac9c13

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

app/index.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,27 @@ <h2 style="font-size: 1.1rem;">Filters</h2>
413413
for (const [facet, values] of Object.entries(selectedFilters)) {
414414
if (values.length === 0) continue;
415415

416+
// Get facet type from schema
417+
const facetConfig = window.searchSchema.facets.find(f => f.field === facet);
418+
const facetType = facetConfig ? facetConfig.type : 'string';
419+
416420
const recipeValue = recipe[facet];
421+
417422
if (Array.isArray(recipeValue)) {
418423
if (!recipeValue.some(v => values.includes(v))) {
419424
return false;
420425
}
421426
} else {
422-
if (!values.includes(recipeValue)) {
423-
return false;
427+
// For boolean facets, convert string values to booleans for comparison
428+
if (facetType === 'boolean') {
429+
const booleanRecipeValue = String(recipeValue);
430+
if (!values.includes(booleanRecipeValue)) {
431+
return false;
432+
}
433+
} else {
434+
if (!values.includes(recipeValue)) {
435+
return false;
436+
}
424437
}
425438
}
426439
}

0 commit comments

Comments
 (0)