* fix tree root element ref
* fix tree node toggle bug
* fix tree node reparenting on the backend
* highlight active home menu on the sidebar
This commit is contained in:
Philipinho
2024-05-20 01:08:31 +01:00
parent 6287f41ef6
commit b06a78b6ec
8 changed files with 85 additions and 42 deletions

View File

@ -124,6 +124,25 @@ export function useTreeMutation<T>(spaceId: string) {
changes: { position: newPosition } as any,
});
const previousParent = args.dragNodes[0].parent;
if (
previousParent.id !== args.parentId &&
previousParent.id !== "__REACT_ARBORIST_INTERNAL_ROOT__"
) {
// if the page was moved to another parent,
// check if the previous still has children
// if no children left, change 'hasChildren' to false, to make the page toggle arrows work properly
const childrenCount = previousParent.children.filter(
(child) => child.id !== draggedNodeId,
).length;
if (childrenCount === 0) {
tree.update({
id: previousParent.id,
changes: { ...previousParent.data, hasChildren: false } as any,
});
}
}
setData(tree.data);
const payload: IMovePage = {