From 70c15dceb012e10f0b5a53c4129691c2333eeaac Mon Sep 17 00:00:00 2001 From: enes Date: Wed, 18 Dec 2024 12:48:47 +0100 Subject: [PATCH] fix(category): show indeterminate on linked category parents --- src/components/Filters/CategoryFilterPopup.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/Filters/CategoryFilterPopup.tsx b/src/components/Filters/CategoryFilterPopup.tsx index 820caa0..efb833e 100644 --- a/src/components/Filters/CategoryFilterPopup.tsx +++ b/src/components/Filters/CategoryFilterPopup.tsx @@ -405,10 +405,22 @@ const CategoryCheckbox: React.FC = ({ const anyChildCombinationSelected = childPaths.some((childPath) => selectedCombinations.includes(childPath) ) - setIsIndeterminate( - anyChildCombinationSelected && !selectedCombinations.includes(pathString) + const anyChildCombinationLinked = childPaths.some( + (childPath) => + linkedHierarchy !== null && linkedHierarchy.includes(childPath) ) - }, [category, name, path, selectedCombinations, selectedSingles]) + setIsIndeterminate( + (anyChildCombinationSelected || anyChildCombinationLinked) && + !selectedCombinations.includes(pathString) + ) + }, [ + category, + linkedHierarchy, + name, + path, + selectedCombinations, + selectedSingles + ]) const handleSingleChange = () => { setIsSingleChecked(!isSingleChecked)