#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)
Change History (10)
Changed 13 years ago by
Attachment: | test_Tree_DnD.html added |
---|
comment:1 Changed 13 years ago by
Milestone: | tbd → 1.3 |
---|---|
Priority: | high → normal |
severity: | critical → normal |
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 12 years ago by
Milestone: | 1.3 → 1.4 |
---|
bumping 1.4 tickets to 1.5, and most 1.3 tickets to 1.4
comment:3 Changed 12 years ago by
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 11 years ago by
Milestone: | 1.4 → 1.5 |
---|
Changed 11 years ago by
Attachment: | dijit.Tree.parentChildDrag.patch added |
---|
Patch to fix this issue.
comment:5 Changed 11 years ago by
Milestone: | 1.5 → 1.4 |
---|---|
Owner: | set to Shane O'Sullivan |
Great, looks good to me, go for it.
comment:6 Changed 11 years ago by
(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 11 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
dojo-release-1.1.1/dijit/tests/tree/test_Tree_DnD.html