Skip to content

Commit 3888d71

Browse files
committed
close disabled tree items
1 parent 6e14f22 commit 3888d71

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

apps/sensenet/src/components/tree/StyledTreeItem.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ export const StyledTreeItem = (props: StyledTreeItemProps) => {
7979
}
8080
}, [props, expandItems, loadCollectionCB, currentPath])
8181

82+
useEffect(() => {
83+
const itemId = String(props.contentvalue.Id)
84+
const itemPath = props.contentvalue.Path
85+
86+
if (!enabledPath.startsWith(itemPath) && !itemPath.startsWith(enabledPath) && expandItems.has(itemId)) {
87+
setExpandItems((prev) => {
88+
const updated = new Set(prev)
89+
updated.delete(itemId)
90+
return updated
91+
})
92+
}
93+
}, [enabledPath, expandItems, props.contentvalue.Id, props.contentvalue.Path, setExpandItems])
94+
8295
const getLabel = () => {
8396
return (
8497
<>

0 commit comments

Comments
 (0)