Skip to content

Commit

Permalink
[ALS-7494] Ensure selected facet counts are updated when required (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPeck authored Oct 23, 2024
1 parent 1cc59ae commit 24e9e1c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/lib/components/explorer/FacetCategory.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@
let facetsToDisplay = facets.filter((f) => !hiddenFacetsForCategory.includes(f.name));
//Put selected facets at the top
$selectedFacets.forEach((facet) => {
let index = facetsToDisplay.findIndex((f) => f.name === facet.name);
if (index > -1) {
facetsToDisplay.splice(index, 1);
}
});
facetsToDisplay.unshift(
...$selectedFacets.filter((facet) => facet.category === facetCategory.name),
const selectedFacetsMap = new Map($selectedFacets.map((facet) => [facet.name, facet]));
facetsToDisplay = facetsToDisplay.filter((f) => !selectedFacetsMap.has(f.name));
const selectedFacetsForCategory = $selectedFacets.filter(
(facet) => facet.category === facetCategory.name,
);
selectedFacetsForCategory.forEach((facet) => {
facet.count = facets.find((f) => f.name === facet.name)?.count || 0;
});
facetsToDisplay.unshift(...selectedFacetsForCategory);
if (textFilterValue) {
//Filter Facets by searched text
const lowerFilterValue = textFilterValue.toLowerCase();
Expand Down

0 comments on commit 24e9e1c

Please sign in to comment.