Skip to content

Commit

Permalink
properly handle opening the first if none is open and no stored value…
Browse files Browse the repository at this point in the history
… found
  • Loading branch information
RFSH committed Aug 28, 2024
1 parent c475905 commit c937a4f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/faceting-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@ export const getInitialFacetOrder = (reference: any): { facetIndex: number, isOp

// no valid stored value was found in storage, so return the annotaion value.
if (!facetOrder || !Array.isArray(facetOrder) || facetOrder.length === 0) {
return facetColumns.map((fc: any, index: number) => {
return { facetIndex: index, isOpen: fc.isOpen };
facetColumns.forEach((fc: any, index: number) => {
if (fc.isOpen) atLeastOneIsOpen = true;
res.push({ facetIndex: index, isOpen: fc.isOpen });
});

// all the facets are closed, open the first one
if (!atLeastOneIsOpen && res.length > 0) {
res[0].isOpen = true;
}
return res;
}

// store the mapping between name and facetIndex
Expand Down

0 comments on commit c937a4f

Please sign in to comment.