Skip to content

Commit 8af30e4

Browse files
authored
Merge pull request #570 from performant-software/RB-fix-range-facets
Add `int64` as possible range facet type
2 parents e00a15d + 39e126c commit 8af30e4

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

packages/core-data/src/components/FacetStateContextProvider.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type Props = {
8989

9090
const TYPE_AUTO = 'auto';
9191
const TYPE_INT_ARRAY = 'int64[]';
92+
const TYPE_INT = 'int64';
9293

9394
/**
9495
* This component renders a context that queries the Typesense collection and returns a list of all facetable
@@ -120,14 +121,17 @@ const FacetStateContextProvider = (props: Props) => {
120121
const listFacets = useMemo(() => (
121122
_.filter(facets, (field: any) => isValid(field)
122123
&& field.facet && field.type !== TYPE_AUTO
123-
&& field.type !== TYPE_INT_ARRAY)
124+
&& field.type !== TYPE_INT_ARRAY
125+
&& field.type !== TYPE_INT)
124126
), [facets, isValid]);
125127

126128
/**
127129
* Memo-ize the range facets.
128130
*/
129131
const rangeFacets = useMemo(() => (
130-
_.filter(facets, (field: any) => isValid(field) && field.facet && field.type === TYPE_INT_ARRAY)
132+
_.filter(facets, (field: any) => (
133+
isValid(field) && field.facet && (field.type === TYPE_INT_ARRAY || field.type === TYPE_INT))
134+
)
131135
), [facets, isValid]);
132136

133137
/**
@@ -165,14 +169,14 @@ const FacetStateContextProvider = (props: Props) => {
165169
key={facet.name}
166170
useRefinementList={props.useRefinementList}
167171
/>
168-
))}
172+
)) }
169173
{ _.map(rangeFacets, (facet) => (
170174
<RangeProxy
171175
attribute={facet.name}
172176
key={facet.name}
173177
useRange={props.useRange}
174178
/>
175-
))}
179+
)) }
176180
{ props.children }
177181
</FacetStateContext.Provider>
178182
);

0 commit comments

Comments
 (0)