From 8eb3a8e3325ec3fb5609a675d80d4a82fd86adb0 Mon Sep 17 00:00:00 2001 From: Raff Viglianti Date: Wed, 30 Oct 2024 16:22:26 -0400 Subject: [PATCH] fixed bug in faceting from url search params --- src/pages/search.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/search.tsx b/src/pages/search.tsx index ceda16d2a..b4b3f7e98 100644 --- a/src/pages/search.tsx +++ b/src/pages/search.tsx @@ -113,19 +113,19 @@ const SearchPage: React.FC = ({data}) => { React.useEffect(() => { const urlParams = new URLSearchParams(window.location.search) // Facets + const newFacets: Facet[] = [] for (const facet of facetFields.keys()) { const fieldName = facetFields.get(facet) || "" const values = urlParams.get(fieldName) if (values) { - const newFacets = [...facets] values.split(",").forEach(val => { if (facets.filter(f => f.cat === fieldName && f.val === val)[0] === undefined) { newFacets.push({cat: fieldName, val}) } }) - setFacets(newFacets) } } + setFacets(newFacets) // Sort const sort = urlParams.get("sort") if (sort && ["asc", "desc"].includes(sort)) {