Skip to content

Commit

Permalink
fixed bug in faceting from url search params
Browse files Browse the repository at this point in the history
  • Loading branch information
raffazizzi committed Oct 30, 2024
1 parent afbb83c commit 8eb3a8e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pages/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ const SearchPage: React.FC<PageProps> = ({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)) {
Expand Down

0 comments on commit 8eb3a8e

Please sign in to comment.