primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
10.29k stars 4.56k forks source link

[p-tree] add possibility to distinguish drop target #15258

Open gcorsaro opened 5 months ago

gcorsaro commented 5 months ago

Some time ago, another issue like this has been opened (#11008). This feature was very useful to understand if a dragged node is dropped inside another node or aside it. Right now the TreeNodeDropEvent only contains the draggedNode, the droppedNode and the index representing the position in the list. However this index value is always the same apart from if the drop is aside or inside the node so there's no way to understand if the node has been moved at the same level (reorder) or inside the drop node. In the past we used the dropIndex property to make such a distinction but it has been removed from the event. Could you please verify why that commit has been removed from any release? Could you please reintroduce a way to make such a distinction? Many thanks for your help

gcorsaro commented 5 months ago

Finally with my team we have found a workaround to make it work. We can use the originalEvent.currentTarget object and check if it contains the class p-treenode-dragover. In this case it's inside the node, otherwise it's aside.

if (!event.originalEvent.currentTarget.classList.value.includes('p-treenode-dragover')) -> aside

Of course this is a workaround not even future proof because if you'll change the class name it won't work anymore. So I hope you'll work on a real solution

jasedwards commented 5 months ago

Agreed, just a workaround. There appear to have been several unpublished breaking changes with the tree control. We were also using dropIndex. If that was not the official way to distinguish where it was dropped then some sort of documentation stating the way to do it would be appreciated. We do pay for pro support so if I should be filing a case elsewhere please let me know.