From 777049922b985442b262f3be762d993fb031fc70 Mon Sep 17 00:00:00 2001
From: Oliver Hader <oliver@typo3.org>
Date: Thu, 1 Jun 2017 15:57:50 +0200
Subject: [PATCH] [BUGFIX] Module menu clicks with slow connections opens
 standalone module

If loading the backend using a slow internet connection an early click on
any item in the module menu on the left side causes the link to be opened
directly. The reason is, that JavaScript and thus click handlers are not
completely loaded yet. Thus, the regular DOM behavior of anchor tags is
executed.

To circumvent this behavior, href-arguments have to be disabled and the
module URL moved to a dedicated new data-attribute. As a result all items
that trigger a module change have to be adjusted as well.

Resolves: #80565
Releases: master, 8.7
Change-Id: I4687e6594eb539acc0d299dc8fc02e6820019911
Reviewed-on: https://review.typo3.org/52996
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../backend/Resources/Private/Templates/ModuleMenu/Main.html  | 2 +-
 .../Templates/ToolbarItems/HelpToolbarItemDropDown.html       | 2 +-
 .../Templates/ToolbarItems/UserToolbarItemDropDown.html       | 4 ++--
 .../sysext/backend/Resources/Public/JavaScript/ModuleMenu.js  | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/typo3/sysext/backend/Resources/Private/Templates/ModuleMenu/Main.html b/typo3/sysext/backend/Resources/Private/Templates/ModuleMenu/Main.html
index 86fc578326f5..5eca3711f3e1 100644
--- a/typo3/sysext/backend/Resources/Private/Templates/ModuleMenu/Main.html
+++ b/typo3/sysext/backend/Resources/Private/Templates/ModuleMenu/Main.html
@@ -19,7 +19,7 @@
 			<ul class="modulemenu-group-container">
 				<f:for each="{mainModule.children}" as="subModule">
 					<li id="{subModule.name}" class="modulemenu-item t3js-mainmodule" data-modulename="{mainModule.name}" data-navigationcomponentid="{subModule.navigationComponentId}" data-navigationframescript="{subModule.navigationFrameScript}" data-navigationframescriptparameters="{subModule.navigationFrameScriptParameters}">
-						<a title="{subModule.description}" href="{subModule.link}" class="modulemenu-item-link">
+						<a href="#" data-link="{subModule.link}" class="modulemenu-item-link" title="{subModule.description}">
 							<span class="modulemenu-icon modulemenu-item-icon">
                                 <f:format.raw>{subModule.icon}</f:format.raw>
 							</span>
diff --git a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItemDropDown.html b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItemDropDown.html
index e911628f2b33..31e0b87215fa 100644
--- a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItemDropDown.html
+++ b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/HelpToolbarItemDropDown.html
@@ -15,7 +15,7 @@
 				{module.icon -> f:format.raw()}
 			</div>
 			<div class="dropdown-table-column dropdown-table-title">
-				<a href="{module.link}" title="{module.description -> f:format.htmlspecialchars()}">
+				<a href="#" data-link="{module.link}" title="{module.description -> f:format.htmlspecialchars()}">
 					{module.title}
 				</a>
 			</div>
diff --git a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/UserToolbarItemDropDown.html b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/UserToolbarItemDropDown.html
index c7e28c39b27d..4acfdb5a99d5 100644
--- a/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/UserToolbarItemDropDown.html
+++ b/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/UserToolbarItemDropDown.html
@@ -15,7 +15,7 @@
 			>
 				<div class="dropdown-table-column dropdown-table-icon">{module.icon -> f:format.raw()}</div>
 				<div class="dropdown-table-column dropdown-table-title">
-					<a href="{module.link}" title="{module.description}">
+					<a href="#" data-link="{module.link}" title="{module.description}">
 						{module.title}
 					</a>
 				</div>
@@ -60,4 +60,4 @@
 		</f:else>
 	</f:if>
 </a>
-</html>
\ No newline at end of file
+</html>
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js
index b4efb16037d7..5b226158bfd0 100644
--- a/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js
+++ b/typo3/sysext/backend/Resources/Public/JavaScript/ModuleMenu.js
@@ -159,7 +159,7 @@ require(
 					navigationComponentId: $subModuleElement.data('navigationcomponentid'),
 					navigationFrameScript: $subModuleElement.data('navigationframescript'),
 					navigationFrameScriptParam: $subModuleElement.data('navigationframescriptparameters'),
-					link: $subModuleElement.find('a').attr('href')
+					link: $subModuleElement.find('a').data('link')
 				};
 			},
 
-- 
GitLab