mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-26 03:11:12 +01: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(() => {
|
||||
jotaiStore.set(hoveredParentFamily(treeId), { parentId: null, index: null });
|
||||
// jotaiStore.set(draggingIdsFamily(treeId), []);
|
||||
jotaiStore.set(draggingIdsFamily(treeId), []);
|
||||
}, [treeId]);
|
||||
|
||||
const handleDragEnd = useCallback(
|
||||
|
||||
@@ -25,13 +25,15 @@ export function TreeDragOverlay<T extends { id: string }>({
|
||||
node={{
|
||||
item: { ...root.item, id: `${root.item.id}_dragging` },
|
||||
parent: null,
|
||||
children: draggingItems.map((id) => {
|
||||
const child = selectableItems.find((i2) => {
|
||||
return i2.node.item.id === id;
|
||||
})!.node;
|
||||
return { ...child, children: undefined };
|
||||
// Remove children so we don't render them in the drag preview
|
||||
}),
|
||||
children: draggingItems
|
||||
.map((id) => {
|
||||
const child = selectableItems.find((i2) => {
|
||||
console.log('i2', i2);
|
||||
return i2.node.item.id === id;
|
||||
})?.node;
|
||||
return child == null ? null : { ...child, children: undefined };
|
||||
})
|
||||
.filter((c) => c != null),
|
||||
}}
|
||||
getItemKey={getItemKey}
|
||||
ItemInner={ItemInner}
|
||||
|
||||
Reference in New Issue
Block a user