1. #11
    Sencha User
    Join Date
    Sep 2007
    Posts
    85
    Vote Rating
    0
    adam.jimenez is on a distinguished road

      0  

    Default


    This extension is excellent, thank you.

    I found a bug where if you select the tree root and a bunch of nodes and then try to click one of them - the selection doesn't change. This is very apparent if you select all of the nodes including root and can't get back to single selection (unless you start ctrl-clicking to deselect first).

    This is my fix:

    change:
    onNodeClick : function(node, e){
    if (e.shiftKey) e.preventDefault();
    // disable select unless not using a dragZone, or a multiselectdragzone
    if ( !this.tree.dragZone || !this.tree.dragZone.isMultiSelect ) {
    this.onMouseDown(node, e);
    this.onMouseUp(node, e);
    }
    },
    to:
    onNodeClick : function(node, e){
    if (e.shiftKey) e.preventDefault();
    // disable select unless not using a dragZone, or a multiselectdragzone
    if ( !this.tree.dragZone || !this.tree.dragZone.isMultiSelect || this.tree.root.isSelected() ) {
    this.onMouseDown(node, e);
    this.onMouseUp(node, e);
    }
    },

  2. #12
    Sencha User
    Join Date
    Mar 2008
    Location
    Adelaide, Australia
    Posts
    71
    Vote Rating
    0
    Deadmeat is on a distinguished road

      0  

    Default


    The actual bug seems to be related to selecting a non-draggable node(ie the root node, which is causing onBeforeDrag to return false.) Dragging the root node is going to cause bugs anyway.

    I think even with your fix, so long as the root node (or any other non-draggable node) is selected, you still can't drag anything. Disabled nodes have the same problems, altho they shouldn't be able to be selected anyway.

    The obvious fixes are:
    • Hide the root, making it unselectable.
    • Make all undraggable nodes unselectable by changing selectNode.
    • Filter the selected nodes to remove undraggable ones, and drag the rest.

    The way the selection and drag work here is basically the wrong way to do it. The right way involves detecting mousedown/up events before the DD (drag/drop) code does (This happens in v4.2 at least). However that's not feasible with the ExtJS 3.x tree as far as I can determine.

    I've uploaded the fix to the github repo.

    The change is here:

    Code:
    getUniqueSelectedNodes: function() {
    	var ret = [];
    	for (var c=0;c<this.selNodes.length;c++) {
    		var parent = this.selNodes[c];
    		if (!parent.draggable && !parent.disabled) continue; // skip root node...
    		ret.push(parent);
    		// nodes are sorted(?) so skip over subsequent nodes inside this one..
    		while ((c+1)<this.selNodes.length && parent.contains(this.selNodes[c+1])) c+;
    	}
    	return ret;
    },
    Sorry the reply has taken so long, apparently I don't get the emails anymore.

    Quote Originally Posted by adam.jimenez View Post
    This extension is excellent, thank you.

    I found a bug where if you select the tree root and a bunch of nodes and then try to click one of them - the selection doesn't change. This is very apparent if you select all of the nodes including root and can't get back to single selection (unless you start ctrl-clicking to deselect first).