[BUGFIX] SelectTreeElement modify expandstate after tree was loaded 78/44078/5
authorAndreas Allacher <andreas.allacher@gmx.at>
Thu, 15 Oct 2015 11:25:52 +0000 (13:25 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 17 Oct 2015 13:05:40 +0000 (15:05 +0200)
Only write ExpandState to user settings via storage after
the corresponding node was loaded in SelectTreeElement

Resolves: #70760
Releases: master

Change-Id: I7f266f7564ee5965955ce8c2b5f29c8b2017c028
Reviewed-on: http://review.typo3.org/44078
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/Element/SelectTreeElement.php

index dcf2262..75ad4f6 100644 (file)
@@ -173,6 +173,7 @@ class SelectTreeElement extends AbstractFormElement
                                onChange: ' . GeneralUtility::quoteJSvalue($onChange) . ',
                                countSelectedNodes: ' . count($selectedNodes) . ',
                                width: ' . (int)$width . ',
+                               rendering: false,
                                listeners: {
                                        click: function(node, event) {
                                                if (typeof(node.attributes.checked) == "boolean") {
@@ -188,24 +189,26 @@ class SelectTreeElement extends AbstractFormElement
                                        },
                                        checkchange: TYPO3.Components.Tree.TcaCheckChangeHandler,
                                        collapsenode: function(node) {
-                                               if (node.id !== "root") {
+                                               if (node.id !== "root" && !this.rendering) {
                                                        top.TYPO3.Storage.Persistent.removeFromList("tcaTrees." + this.ucId, node.attributes.uid);
                                                }
                                        },
                                        expandnode: function(node) {
-                                               if (node.id !== "root") {
+                                               if (node.id !== "root" && !this.rendering) {
                                                        top.TYPO3.Storage.Persistent.addToList("tcaTrees." + this.ucId, node.attributes.uid);
                                                }
                                        },
                                        beforerender: function(treeCmp) {
+                                           this.rendering = true;
                                                // Check if that tree element is already rendered. It is appended on the first tceforms_inline call.
                                                if (Ext.fly(treeCmp.getId())) {
                                                        return false;
                                                }
-                                       }' . ($expanded ? ',
+                                       },
                                        afterrender: function(treeCmp) {
-                                               treeCmp.expandAll();
-                                       }' : '') . '
+                                           ' . ($expanded ? 'treeCmp.expandAll();' : '') . '
+                                           this.rendering = false;
+                                       }
                                },
                                tcaMaxItems: ' . ($config['maxitems'] ? (int)$config['maxitems'] : 99999) . ',
                                tcaSelectRecursiveAllowed: ' . ($appearance['allowRecursiveMode'] ? 'true' : 'false') . ',