From fea8a24e53cb7a3f2ea0a12aa8737c77915fd298 Mon Sep 17 00:00:00 2001 From: Helmut Hummel <typo3@helhum.io> Date: Sun, 19 Nov 2017 21:12:18 +0100 Subject: [PATCH] [BUGIFX] Fix JS error in filtering page tree While fixing #82877 a mistake was introduced which leads to a JavaScript error when filtering the page tree. Problem is that PageTree.select() is called with the filter tree currently active, but this method is only functional for the full page tree since quite a while now. We now avoid calling this method and document the behavior properly in method annotations. Additionally a typo in the variable name is fixed, which lead to a jquery warning when selecting a page. Resolves: #83039 Releases: master, 8.7 Change-Id: I6440fb7f6cfd6ead8b5b29dea7c5081dd688a5c3 Reviewed-on: https://review.typo3.org/54688 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Sebastian Fischer <typo3@evoweb.de> Tested-by: Sebastian Fischer <typo3@evoweb.de> Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Reviewed-by: Andreas Fernandez <typo3@scripting-base.de> Tested-by: Andreas Fernandez <typo3@scripting-base.de> --- .../extjs/components/pagetree/javascript/actions.js | 2 +- .../extjs/components/pagetree/javascript/app.js | 6 +++--- .../extjs/components/pagetree/javascript/toppanel.js | 11 ++++++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/actions.js b/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/actions.js index f3a97142d6c2..2cfc3c439290 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/actions.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/actions.js @@ -723,7 +723,7 @@ require(['TYPO3/CMS/Backend/Utility'], function(Utility) { TYPO3.Backend.ContentContainer.setUrl( currentSubScript + separator + 'id=' + node.attributes.nodeData.id ).then(function () { - tree.selectNode(selectNode); + tree.selectNode(node); }); }, diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/app.js b/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/app.js index 8bc06bf20708..a25e0c9d9c77 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/app.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/app.js @@ -347,7 +347,7 @@ TYPO3.Components.PageTree.App = Ext.extend(Ext.Panel, { }, /** - * Selects a node defined by the page id. + * Selects a node on the main tree defined by the page id. * * @param {int} pageId */ @@ -390,13 +390,13 @@ TYPO3.Components.PageTree.App = Ext.extend(Ext.Panel, { var self = this; Ext.each(nodePaths, function(nodePath) { callback('/root/' + nodePath.join('/'), 'id', function() { - self.mainTree.selectNode(self.getSelected()); + self.mainTree.selectNode(self.mainTree.getSelectionModel().getSelectedNode()); }); }); }, /** - * Returns the currently selected node + * Returns the currently selected node of the currently active tree * * @return {Ext.tree.TreeNode} */ diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/toppanel.js b/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/toppanel.js index 3f46ce69b27c..f460be624aac 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/toppanel.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/toppanel.js @@ -233,7 +233,7 @@ require(['TYPO3/CMS/Backend/Utility'], function(Utility) { this.filteringIndicator = null; } } else { - var selectedNode = this.app.getSelected(); + var selectedNodeOnMainTree = this.app.getSelected(); this.app.activeTree = this.filteringTree; if (!this.filteringIndicator) { @@ -245,8 +245,13 @@ require(['TYPO3/CMS/Backend/Utility'], function(Utility) { textField.setHideTrigger(false); this.tree.hide(); this.filteringTree.show().refreshTree(function () { - if (selectedNode) { - this.app.select(selectedNode.attributes.nodeData.id, false); + if (selectedNodeOnMainTree) { + // Try to select the currently selected node in the main tree in the filter tree + var tree = this.app.getTree(); + var node = tree.getRootNode().findChild('realId', selectedNodeOnMainTree.attributes.nodeData.id, true); + if (node) { + tree.selectPath(node.getPath()); + } } textField.focus(); }, this); -- GitLab