[BUGIFX] Fix JS error in filtering page tree 89/54689/2
authorHelmut Hummel <typo3@helhum.io>
Sun, 19 Nov 2017 20:12:18 +0000 (21:12 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Mon, 20 Nov 2017 07:29:54 +0000 (08:29 +0100)
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/54689
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/app.js
typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/toppanel.js

index 8bc06bf..a25e0c9 100644 (file)
@@ -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}
         */
index c370693..55fa3c7 100644 (file)
@@ -237,7 +237,7 @@ TYPO3.Components.PageTree.TopPanel = Ext.extend(Ext.Panel, {
                                this.filteringIndicator = null;
                        }
                } else {
-                       var selectedNode = this.app.getSelected();
+                       var selectedNodeOnMainTree = this.app.getSelected();
                        this.app.activeTree = this.filteringTree;
 
                        if (!this.filteringIndicator) {
@@ -249,8 +249,13 @@ TYPO3.Components.PageTree.TopPanel = Ext.extend(Ext.Panel, {
                        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);