Bug Report and Inquiry on Node Dragging in he-tree Library
Closed this issue · 1 comments
Dear Developer,
I would like to extend my heartfelt gratitude for creating such an excellent library. I am writing to report a potential bug and seek guidance on a specific functionality.
Bug Description:
Upon the initial drag of a Node, the value of dragContext.targetInfo.dragNode
is null.
I am aiming to achieve the functionality where after dragging a node within the tree and dropping it, I can retrieve the position where the node is placed (i.e., the parent and index).
Here is the code snippet I am utilizing:
<template>
<Draggable class="mtl-tree menu-font q-pl-sm"
ref="menuTree"
:default-open="false"
v-model="treeData"
@drop="dropToggle"
:eachDroppable="eachDroppable"
:rootDroppable="rootDroppable"
treeLine>
</template>
......
<script setup lang="ts">
function dropToggle() {
let indexAfterDrop = 0;
for (let i = 0; i < dragContext.startInfo.siblings.length; i++) {
if (dragContext.startInfo.siblings[i]?.data.name == null) {
console.log('dropToggle siblings %d ->', i, dragContext.startInfo.siblings[i]);
indexAfterDrop = i;
}
}
console.log('dropToggle from %d -> %d', dragContext.startInfo.indexBeforeDrop, indexAfterDrop);
console.log('dropToggle targetInfo', dragContext.targetInfo.dragNode)
}
</script>
However, when I first drag an element, the output of dragContext.targetInfo.dragNode
is consistently null. I am uncertain if this is a bug and would appreciate it if you could take a look.
Additionally, I would like to inquire about the proper implementation to obtain the dragged node and its position information after the drag operation.
I hope to hear from you soon.
Yours sincerely,
Kermit
All right, just use dragContext.dragNode.