mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-11 15:22:54 +02:00
Fix crash when delete after drag
This commit is contained in:
@@ -300,7 +300,7 @@ function TreeInner<T extends { id: string }>(
|
|||||||
|
|
||||||
const clearDragState = useCallback(() => {
|
const clearDragState = useCallback(() => {
|
||||||
jotaiStore.set(hoveredParentFamily(treeId), { parentId: null, index: null });
|
jotaiStore.set(hoveredParentFamily(treeId), { parentId: null, index: null });
|
||||||
// jotaiStore.set(draggingIdsFamily(treeId), []);
|
jotaiStore.set(draggingIdsFamily(treeId), []);
|
||||||
}, [treeId]);
|
}, [treeId]);
|
||||||
|
|
||||||
const handleDragEnd = useCallback(
|
const handleDragEnd = useCallback(
|
||||||
|
|||||||
@@ -25,13 +25,15 @@ export function TreeDragOverlay<T extends { id: string }>({
|
|||||||
node={{
|
node={{
|
||||||
item: { ...root.item, id: `${root.item.id}_dragging` },
|
item: { ...root.item, id: `${root.item.id}_dragging` },
|
||||||
parent: null,
|
parent: null,
|
||||||
children: draggingItems.map((id) => {
|
children: draggingItems
|
||||||
const child = selectableItems.find((i2) => {
|
.map((id) => {
|
||||||
return i2.node.item.id === id;
|
const child = selectableItems.find((i2) => {
|
||||||
})!.node;
|
console.log('i2', i2);
|
||||||
return { ...child, children: undefined };
|
return i2.node.item.id === id;
|
||||||
// Remove children so we don't render them in the drag preview
|
})?.node;
|
||||||
}),
|
return child == null ? null : { ...child, children: undefined };
|
||||||
|
})
|
||||||
|
.filter((c) => c != null),
|
||||||
}}
|
}}
|
||||||
getItemKey={getItemKey}
|
getItemKey={getItemKey}
|
||||||
ItemInner={ItemInner}
|
ItemInner={ItemInner}
|
||||||
|
|||||||
Reference in New Issue
Block a user