(info)
| 642 | } |
| 643 | |
| 644 | const handleDrop: TreeProps['onDrop'] = (info) => { |
| 645 | const dragKey = info.dragNode.key as string |
| 646 | const dropKey = info.node.key as string |
| 647 | const dropNodeData = info.node as unknown as TreeNodeData<TItem, TFolder> |
| 648 | |
| 649 | const draggedItem = items.find((p) => p.id === dragKey) || folders.find((f) => f.id === dragKey) |
| 650 | if (!draggedItem) return |
| 651 | |
| 652 | if (dropNodeData?.isFolder && !info.dropToGap) { |
| 653 | const itemsInFolder = getItemsAtLevel(dropKey, dragKey) |
| 654 | batchUpdateItemsOrder([draggedItem, ...itemsInFolder], dropKey) |
| 655 | } else if (info.dropToGap) { |
| 656 | const targetItem = |
| 657 | items.find((p) => p.id === dropKey) || folders.find((f) => f.id === dropKey) |
| 658 | const targetParentFolderId = targetItem?.parentFolderId |
| 659 | const sameLevelItems = getItemsAtLevel(targetParentFolderId, dragKey) |
| 660 | const targetIndex = sameLevelItems.findIndex((item) => item.id === dropKey) |
| 661 | const dropPos = info.dropPosition |
| 662 | const targetPos = Number(info.node.pos.split('-').pop()) |
| 663 | const insertIndex = dropPos > targetPos ? targetIndex + 1 : targetIndex |
| 664 | sameLevelItems.splice(insertIndex, 0, draggedItem) |
| 665 | batchUpdateItemsOrder(sameLevelItems, targetParentFolderId) |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | const handleAllowDrop: TreeProps['allowDrop'] = ({ dropNode, dropPosition }) => { |
| 670 | const dropNodeData = dropNode as TreeNodeData<TItem, TFolder> |
nothing calls this directly
no test coverage detected