Opened 12 years ago

Closed 12 years ago

#9831 closed defect (fixed)

Tree: treenode is null exception

Reported by: Jean-Rubin Leonard Owned by: bill
Priority: high Milestone: 1.4
Component: Dijit Version: 1.3.2
Keywords: tree dnd treenode null Cc:
Blocked By: Blocking:


Hi, there is a a problem with tree nodes that when you drag and drop a tree node into another one it will crash apparently randomly with an error message treenode is null or node is null. According to Bill Keese, The behavior can be reproduced in the test_Tree_Dnd.html test case. I have witnessed that the problem happens in the tree's dndSource.js but could go no further. This is currently preventing inter tree dnd from occuring outside dnd does not seem to be affected. JR

Change History (4)

comment:1 Changed 12 years ago by bill

Component: GeneralDijit
Milestone: tbd1.4
Owner: changed from anonymous to bill
Status: newassigned
Summary: treenode is null bugTree: treenode is null exception

comment:2 Changed 12 years ago by bill

(In [20018]) When starting to drag a node (either a tree node or a random node from another drag source), multiple dijit.Tree's might call dojo.dnd.manager().overSource(this). Clearly, only the drag source should make that call, since the mouse is over the drag source.

This bug was masking the "treeNode is null" error in test_Tree_DnD.html (since it has two trees), and probably causing some other problems too although I'm not sure what.

Refs #9831 !strict.

comment:3 Changed 12 years ago by bill

The basic issue here is that on drop, dijit.Tree's dndSource::onDndDrop(nodes, source) is called, and source.selection sometimes doesn't match nodes.

The reason is that drop causes an mouse up event (right before onDndDrop() is called), which has some strange handler code in dijit/tree/_dndSelector.js::onMouseUp(), as well as similar code in dojo/dnd/Selector.js, to change the selection. According to Eugene this code is to handle the case where:

1) User selected several items, and by mistake click on one of them

2) She can move a mouse and and release a button: the selection wouldn't change.

3) If she releases a mouse immediately, the current item (under mouse) will be selected, the old selection will be gone.

The reason the problem is intermittent is that sometimes _dndSelector.js::onMouseDown() sets this.simpleSelection to true and sometimes it doesn't. Haven't traced down why yet.

comment:4 Changed 12 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [20021]) Minimal fix for intermittent "childTreeNode is null" exceptions when dragging and dropping within a tree. There's a bunch of code in tree/_dndSelector.js (copied from dojo/dnd/Selector.js) about onMouseUp changing the selection; that code was interfering with the drop operation (which shouldn't change the selection because we need it to perform the drop).

I fixed the error, although it's unclear if all the onMouseUp/onMouseMove/this.simpleSelection code is even necessary. Added a TODO to the code for that.

Also changed dragThreshold to 5 because 0 causes some problems when a node is dragged accidentally and then dropped, causing some errors because the avatar is green when it should be red (can't drop a node onto itself).

Fixes #9831 !strict.

Note: See TracTickets for help on using tickets.