Opened 8 years ago

Closed 8 years ago

#12709 closed defect (duplicate)

Node selection fails in dijit.Tree after deleting a node

Reported by: mwbiz Owned by:
Priority: high Milestone: tbd
Component: Dijit Version: 1.6.0
Keywords: Cc:
Blocked By: Blocking:

Description

If you have a dijit.Tree with a dijit.tree._dndSelector set as the trees dndController and you delete one or more nodes, subsequent node selection throws an error and selection gets messed up.

A fix that seems to work is to add the following line to the the Tree's _onItemDelete method:

if(nodes){
  dojo.forEach(nodes,function(node){
    var parent = node.getParent();
    //INSERT THE BELOW IF STATEMENT
    if (this.dndController && this.dndController.removeTreeNode) {
      this.dndController.removeTreeNode();
    } //end if
    //CONTINUE REGULAR DOJO CODE HERE
  });
}

The reason the error happens is because the node id destroyed with node.destroyRecursive and then the subsequent call to _dndSelector.setSelection fails during the call to node.setSelected(false) as it tries to unselect the deleted node. With the above call it deselects the item prior to deletion and everything works.

This only happens in version 1.6.

Change History (2)

comment:1 in reply to:  description Changed 8 years ago by mwbiz

Replying to mwbiz: Sorry, missed the node in my .removeTreeNode(), it should be:

if(nodes){
  dojo.forEach(nodes,function(node){
    var parent = node.getParent();
    //INSERT THE BELOW IF STATEMENT
    if (this.dndController && this.dndController.removeTreeNode) {
      this.dndController.removeTreeNode(node);
    } //end if
    //CONTINUE REGULAR DOJO CODE HERE
  });
}

comment:2 Changed 8 years ago by bill

Component: GeneralDijit
Resolution: duplicate
Status: newclosed

Yes, I believe this is fixed in [24104], closing as dup of #12486.

Note: See TracTickets for help on using tickets.