[BUGIFX] Fix JS error in filtering page tree 88/54688/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:26:25 +0000 (08:26 +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/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>
typo3/sysext/backend/Resources/Public/JavaScript/extjs/components/pagetree/javascript/actions.js
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 f3a9714..2cfc3c4 100644 (file)
@@ -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);
                        });
                },
 
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 3f46ce6..f460be6 100644 (file)
@@ -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);