diff --git a/src/app/components/tree/tree.ts b/src/app/components/tree/tree.ts
index d313b9c4384..ddb938e5497 100755
--- a/src/app/components/tree/tree.ts
+++ b/src/app/components/tree/tree.ts
@@ -513,7 +513,7 @@ export class UITreeNode implements OnInit {
+ (drop)="onDrop($event)" (dragover)="onDragOver($event)" (dragenter)="onDragEnter()" (dragleave)="onDragLeave($event)">
@@ -1028,30 +1028,45 @@ export class Tree implements OnInit,AfterContentInit,OnChanges,OnDestroy,Blockab
if (this.droppableNodes && (!this.value || this.value.length === 0)) {
event.preventDefault();
let dragNode = this.dragNode;
+
if (this.allowDrop(dragNode, null, this.dragNodeScope)) {
let dragNodeIndex = this.dragNodeIndex;
- this.dragNodeSubNodes.splice(dragNodeIndex, 1);
this.value = this.value||[];
- if (this.value.length === 0) {
+ if (this.validateDrop) {
+ this.onNodeDrop.emit({
+ originalEvent: event,
+ dragNode: dragNode,
+ dropNode: null,
+ index: dragNodeIndex,
+ accept: () => {
+ this.processTreeDrop(dragNode, dragNodeIndex);
+ }
+ });
+ }
+ else {
this.onNodeDrop.emit({
originalEvent: event,
dragNode: dragNode,
dropNode: null,
index: dragNodeIndex
- })
+ });
+
+ this.processTreeDrop(dragNode, dragNodeIndex);
}
-
- this.value.push(dragNode);
-
- this.dragDropService.stopDrag({
- node: dragNode
- });
}
}
}
- onDragEnter(event) {
+ processTreeDrop(dragNode, dragNodeIndex) {
+ this.dragNodeSubNodes.splice(dragNodeIndex, 1);
+ this.value.push(dragNode);
+ this.dragDropService.stopDrag({
+ node: dragNode
+ });
+ }
+
+ onDragEnter() {
if (this.droppableNodes && this.allowDrop(this.dragNode, null, this.dragNodeScope)) {
this.dragHover = true;
}