Skip to content

Commit

Permalink
hide facets if has no values to show
Browse files Browse the repository at this point in the history
  • Loading branch information
zotya committed Nov 15, 2023
1 parent 96dac21 commit 0a1740a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Facet from '../Facet';
const AccordionFacetWrapper = (props) => {
const { collapsable = true, field, label } = props;
const searchContext = useSearchContext();
const { filters } = searchContext;
const { facets, filters } = searchContext;

const hasFilter = !!filters.find((filter) => field === filter.field);
const [openFacets] = useAtom(openFacetsAtom);
Expand Down Expand Up @@ -42,7 +42,7 @@ const AccordionFacetWrapper = (props) => {

let isOpened = openFacets[field]?.opened || false;
const [counter, setCounter] = React.useState(0);

if (facets[field] === undefined) return null;
return collapsable ? (
<Accordion>
<Accordion.Title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const DropdownFacetWrapper = (props) => {
searchContext: facetSearchContext,
applySearch,
} = useProxiedSearchContext(rawSearchContext);
const { filters } = facetSearchContext;
const { facets, filters } = facetSearchContext;

const { appConfig } = useAppConfig();
const facet = appConfig.facets?.find((f) => f.field === field);
Expand Down Expand Up @@ -64,6 +64,7 @@ const DropdownFacetWrapper = (props) => {

const { width } = useWindowDimensions();
const isSmallScreen = width < SMALL_SCREEN_SIZE;
if (facets[field] === undefined) return null;

return (
<>
Expand Down

0 comments on commit 0a1740a

Please sign in to comment.