Tree drag'n'drop incorrect behaiviour
I'm submitting a ... (check one with "x")
[X] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Plunkr Case (Bug Reports) http://plnkr.co/edit/KJD6VkjXYEg9qlAIBpCx?p=preview
Current behavior DropNode in onNodeDrop event is incorrect when drop to the same level. It contains node that bottom of dropped place. E.g. (see plunker): Drag Movies and place it between Documents and Pictures. DropNode will be Pictures.
Expected behavior DropNode should reflect correct parent node.
Minimal reproduction of the problem with instructions
- drag node
- drop to the same level (between nodes)
- see dropNode in onNodeDrop event
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
-
Angular version: 2.0.X 5.2.2
-
PrimeNG version: 2.0.X 5.0.2 / 5.2.0-rc.2
-
Browser: all
-
Language: [all | TypeScript X.X | ES6/7 | ES5]
-
Node (for AoT issues):
node --version=
Sorry, Unable to replicate.
This is happening to me too. Basically there is no way to tell if the user dropped on a node or on a drop point next to a node. Obviously the tree knows because the item is placed in the correct spot. but that knowledge is not passed in to the event
@jasedwards I encountered this issue, too. There is a way to tell. If $event.dropIndex == null then the drop occurred directly on a node. If $event.dropIndex is a number, then the drop occurred on a drop point next to a node (with the number indicating where).
@davidda I have the same issue. The expected behavior is that the droppable node level should always be same as draggable node level. Current behavior: I can be able to make a grand child node into a Child node and parent node. A child node into a parent node, grand child node and a parent node as child node and grand child node. I want to drag and drop these nodes through out the tree without disturbing the structure. A Parent should always be a parent, a child should always be a child and a grand child should always be grand child even if we change them from one node to other. ` Data= [ { "label": "Documents", "data": "Documents Folder", "expandedIcon": "fa fa-folder-open", "collapsedIcon": "fa fa-folder", "children": [{ "label": "Work", "data": "Work Folder", "expandedIcon": "fa fa-folder-open", "collapsedIcon": "fa fa-folder", "children": [{"label": "Expenses.doc", "icon": "fa fa-file-word-o", "data": "Expenses Document"}, {"label": "Resume.doc", "icon": "fa fa-file-word-o", "data": "Resume Document"}] }, { "label": "Home", "data": "Home Folder", "expandedIcon": "fa fa-folder-open", "collapsedIcon": "fa fa-folder", "children": [{"label": "Invoices.txt", "icon": "fa fa-file-word-o", "data": "Invoices for this month"}] }] }, { "label": "Pictures", "data": "Pictures Folder", "expandedIcon": "fa fa-folder-open", "collapsedIcon": "fa fa-folder", "children": [ {"label": "barcelona.jpg", "icon": "fa fa-file-image-o", "data": "Barcelona Photo"}, {"label": "logo.jpg", "icon": "fa fa-file-image-o", "data": "PrimeFaces Logo"}, {"label": "primeui.png", "icon": "fa fa-file-image-o", "data": "PrimeUI Logo"}] }, { "label": "Movies", "data": "Movies Folder", "expandedIcon": "fa fa-folder-open", "collapsedIcon": "fa fa-folder", "children": [{ "label": "Al Pacino", "data": "Pacino Movies", "children": [{"label": "Scarface", "icon": "fa fa-file-video-o", "data": "Scarface Movie"}, {"label": "Serpico", "icon": "fa fa-file-video-o", "data": "Serpico Movie"}] }, { "label": "Robert De Niro", "data": "De Niro Movies", "children": [{"label": "Goodfellas", "icon": "fa fa-file-video-o", "data": "Goodfellas Movie"}, {"label": "Untouchables", "icon": "fa fa-file-video-o", "data": "Untouchables Movie"}] }] } ]
onDrop(event) {
if (event.dragNode.parent === event.dropNode.parent && event.dragNode !== event.dropNode
&& event.dropIndex) {
event.accept();
}
console.log(event.dropIndex,'Drop Index');
}
I have below code in html
<p-tree [value]="Data" draggableNodes="true" droppableNodes="true" (onNodeDrop)="onDrop($event)">`
There is clearly this bug present in newest release (10.0.0)
See screenshots:
one would expect TT to be dropped on A1 while event states it was dropped on B1
which actually makes no difference in the data (as TT is already a child of B1) and no data refresh happens (but tree is displaying the dropped state which disappears after page reload)

The same issue, I don't get why it's closed. It's easy to reproduce. And it's a stopper to implement changing the order of the files inside a folder for example. Because you are not able to determine when a file dropped in the same folder where it was.
"primeng": "10.0.3"
I can confirm that we have exactly the same issue. Like my fellow just above, we're using [email protected]. Is there any workaround available before we try to build a specific one? Thanks!
11.2.0 version. Still wrong dropNode (also dropIndex) in this case
I'm using 14.0.2 and the dropNode is incorrect unfortunately... Does anyone have a workaround?