phphe / he-tree-vue

A draggable sortable vue tree component, with dragging placeholder, types definition.

Home Page:https://hetree.phphe.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to access dragged node?

balint80 opened this issue · comments

Hello, I am using he-tree 2.0.10, and trying to get the draged node from the startTree like so:

onDrop(store) {
window.console.log(store.startPath)
window.console.log(store.startTree.getNodeByPath(store.startPath))
}

[0, 1]
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'children' of undefined
at TreeData.iteratePath$ (helper-js.esm.js?0fa5:986)
at tryCatch (runtime.js?96cf:63)
at Generator.invoke [as _invoke] (runtime.js?96cf:293)
at Generator.eval [as next] (runtime.js?96cf:118)
at Object.n (helper-js.esm.js?0fa5:57)
at TreeData.getAllNodes (helper-js.esm.js?0fa5:1074)
at TreeData.getNode (helper-js.esm.js?0fa5:1089)
at VueComponent.getNodeByPath (he-tree-vue.esm.js?94dd:174)
at VueComponent.onDrop (ProjectBrowser2.vue?ac95:192)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)

However at this point, startTree is already modified, and contains the state after the drop, and so the startPath is either pointing to a wrong node or to a non-existent one.

Am I doing something wrong, or is this an issue with he-tree?

Thanks a lot in advance!

(PS: onDrop is bound to the drop event. I also tried the before-drop and change events but for some reason they did not fire)

Sorry, I just found the solution. The dragged node is store in the store.dragNode attribute, no need to use the path to access it. :)