Opened 11 years ago

Closed 10 years ago

Last modified 5 years ago

#7140 closed defect (fixed)

Tree: The whole tree structure will break up if we drag-n-drop a parent node onto a child node.

Reported by: binspaul Owned by: Shane O'Sullivan
Priority: high Milestone: 1.4
Component: Dijit Version: 1.1.1
Keywords: Tree, DnD Cc:
Blocked By: Blocking:

Description

The whole tree hierarchy will break up if we drag-n-drop a parent node onto a child node. It is also present in the example given in the file : '/dojo-release-1.1.1/dijit/tests/tree/test_Tree_DnD.html'. In the Collections tree example given, just drag-n-drop the Fruits node onto the Citrus node. The whole tree structure will break-up producing exception. Ideally, it should not be allowed to drop a node onto its child node.

Attachments (2)

test_Tree_DnD.html (6.3 KB) - added by binspaul 11 years ago.
dojo-release-1.1.1/dijit/tests/tree/test_Tree_DnD.html
dijit.Tree.parentChildDrag.patch (2.0 KB) - added by Shane O'Sullivan 10 years ago.
Patch to fix this issue.

Download all attachments as: .zip

Change History (10)

Changed 11 years ago by binspaul

Attachment: test_Tree_DnD.html added

dojo-release-1.1.1/dijit/tests/tree/test_Tree_DnD.html

comment:1 Changed 11 years ago by bill

Milestone: tbd1.3
Priority: highnormal
severity: criticalnormal
Summary: The whole tree structure will break up if we drag-n-drop a parent node onto a child node.Tree: The whole tree structure will break up if we drag-n-drop a parent node onto a child node.

Hmm, I thought we had another ticket open about this but I can't find it.

Note that this is a little more complicated than the ticket description since you can drag multiple TreeNodes at once.

comment:2 Changed 11 years ago by bill

Milestone: 1.31.4

bumping 1.4 tickets to 1.5, and most 1.3 tickets to 1.4

comment:3 Changed 11 years ago by millennium

Here's the part code I wrote to fix this bug. It's implemented in "checkItemAcceptance". But it isn't that hard to merge into dndSource.

checkItemAcceptance: function(target,source,position) {
  var _checkChildren = function(sourceNode, treeNode) {
  	if (sourceNode.isTreeNode) {	//SomeHow getChildren() gives something else than treeNodes only
    	if (treeNode == sourceNode) {
				return false;
			}
   			
   		var result = true;
 			var children = sourceNode.getChildren();
   		for (var i in children) {
   			if (!_checkChildren(children[i], treeNode)) {
   				result = false;
   				break;
   			}
   		}	
   		return result;
		}
		return true;
  }
    	
  var treeNode = dijit.getEnclosingWidget(target);
  if (position != "over") {
  	treeNode = treeNode.getParent();
  }
  if (treeNode.isTreeNode) {
 		for (var i in source.selection){
			var sourceNode = dijit.getEnclosingWidget(source.selection[i]);
			if (!(sourceNode && _checkChildren(sourceNode, treeNode))) {
				return false;
			}	
		}
		return true;
	}			
	return false;
}

Note that this is a little more complicated than the ticket description since you can drag multiple TreeNodes? at once.

If one of the treeNodes can't be dropt in the specific location, You can't drop your selection in there. (IMHO)

comment:4 Changed 10 years ago by bill

Milestone: 1.41.5

Changed 10 years ago by Shane O'Sullivan

Patch to fix this issue.

comment:5 Changed 10 years ago by bill

Milestone: 1.51.4
Owner: set to Shane O'Sullivan

Great, looks good to me, go for it.

comment:6 Changed 10 years ago by Shane O'Sullivan

(In [20268]) Refs #7140 Fixes the simple case where a tree node is dragged into one of it's child nodes. This does not solve the more complex issue of a tree node with multiple parents being dragged into a child which cannot be readily determined by the tree. Such cases will have to be solved by the user, with whatever data store they happen to be using.

comment:7 Changed 10 years ago by Shane O'Sullivan

Resolution: fixed
Status: newclosed

comment:8 Changed 5 years ago by Bill Keese <bill@…>

In af40c3922c7a26e0bb8e3d7041a2c6a25b8bf19f/dijit:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 
Note: See TracTickets for help on using tickets.