Skip to content

Commit

Permalink
Fix primefaces#11513: Tree wrong dnd index for sibling going down
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Feb 23, 2024
1 parent b8c7175 commit 913d03a
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,23 @@ PrimeFaces.widget.VerticalTree = PrimeFaces.widget.BaseTree.extend({
draggedSourceKeys = draggedSourceKeys.filter(function(key) {
return $.inArray(key, $this.invalidSourceKeys) === -1;
});

// #11513 dndIndex is based on whether you are dragging up or down
var dndIndex = dropPoint.prevAll('li.ui-treenode').length;
if (parseInt(dragNodeKey) < dndIndex) {
var nextDndIndex = dropPoint.nextAll('li.ui-treenode').length;
if (nextDndIndex > 0) {
dndIndex = nextDndIndex;
}
}

if (draggedSourceKeys && draggedSourceKeys.length) {
draggedSourceKeys = draggedSourceKeys.reverse().join(',');
$this.fireDragDropEvent({
'dragNodeKey': draggedSourceKeys,
'dropNodeKey': dropNodeKey,
'dragSource': dragSource.id,
'dndIndex': dropPoint.prevAll('li.ui-treenode').length,
'dndIndex': dndIndex,
'transfer': transfer,
'isDroppedNodeCopy': isDroppedNodeCopy
});
Expand Down

0 comments on commit 913d03a

Please sign in to comment.