Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedupe single valued hierarchical parents/children #3599

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions context/app/static/js/components/search/Facets/TermFacet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useCallback } from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import IndeterminateCheckBoxOutlinedIcon from '@mui/icons-material/IndeterminateCheckBoxOutlined';
import Accordion from '@mui/material/Accordion';
Expand Down Expand Up @@ -231,6 +232,22 @@ export const HierarchicalTermFacetItem = React.memo(function HierarchicalTermFac
const hasChildBuckets = childBuckets?.length;
const childValues = childBuckets.map((b) => b.key);

if (childValues.length === 1 && childBuckets[0].key === label) {
return (
// 26px is the width of the Accordion's expand icon.
<Box pr="26px">
<HierarchicalFacetParent
childValues={childValues}
label={label}
field={field}
title={title}
{...rest}
indeterminate={childState?.size > 0 && !childValues.every((v) => childState?.has(v))}
/>
</Box>
);
}

return (
<Accordion
sx={{
Expand Down
Loading