fix(category): show indeterminate on linked category parents

This commit is contained in:
enes 2024-12-18 12:48:47 +01:00
parent 52f1735d40
commit 70c15dceb0

View File

@ -405,10 +405,22 @@ const CategoryCheckbox: React.FC<CategoryCheckboxProps> = ({
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)