From 69d349749784c3b0a652e6580c19dac962cee4b1 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 4 Jun 2012 11:05:05 +0200 Subject: [PATCH] MINOR Fixed node deselection when changing areas (e.g. "pages" to "edit page") --- admin/javascript/LeftAndMain.Tree.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/admin/javascript/LeftAndMain.Tree.js b/admin/javascript/LeftAndMain.Tree.js index 7fbfbe23c..9c0134632 100644 --- a/admin/javascript/LeftAndMain.Tree.js +++ b/admin/javascript/LeftAndMain.Tree.js @@ -247,20 +247,22 @@ newNode.find('a:first').html(title).attr('href', ss.i18n.sprintf( self.data('urlEditpage'), id )); - self.jstree('deselect_node', parentNode); + self.jstree('deselect_all'); self.jstree('select_node', newNode); } ); - // set current tree element + } + + if(node.length) { + // set correct parent (only if it has changed) + if(parentID && parentID != node.parents('li:first').data('id')) { + this.jstree('move_node', node, parentNode.length ? parentNode : -1, 'last'); + } + + // Only single selection is supported on initial load + this.jstree('deselect_all'); this.jstree('select_node', node); } - - // set correct parent (only if it has changed) - if(parentID && parentID != node.parents('li:first').data('id')) { - this.jstree('move_node', node, parentNode.length ? parentNode : -1, 'last'); - } - - this.jstree('select_node', node); } else { // If no ID exists in a form view, we're displaying the tree on its own, // hence to page should show as active