From 26f68b8ae8de29754ae7b74cd06dfa9a9268b105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20G=C3=BCnther?= <mail@markus-guenther.de> Date: Mon, 20 Nov 2017 09:18:27 +0100 Subject: [PATCH] [BUGFIX] Prevent javascript error in backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding a condition to check if a backend user has permissions on the search to prevent a JS error while initializing the autocomplete module. Also check if a module is available to start with. Fixes: #82969 Releases: master, 8.7, 7.6 Change-Id: If2827902443ff7411d9b2c1050213be3e0d78fb6 Reviewed-on: https://review.typo3.org/54714 Reviewed-by: Markus Günther <mail@markus-guenther.de> Tested-by: Markus Günther <mail@markus-guenther.de> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Reviewed-by: Henning Liebe <h.liebe@neusta.de> Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com> Tested-by: Alexander Opitz <opitz.alexander@googlemail.com> --- .../backend/Resources/Public/JavaScript/LiveSearch.js | 10 ++++++---- .../backend/Resources/Public/JavaScript/modulemenu.js | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js b/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js index c6d9dfa643e3..4bea1e5c6a73 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js @@ -87,10 +87,12 @@ define(['jquery', 'jquery/autocomplete', 'TYPO3/CMS/Backend/jquery.clearable'], evt.preventDefault(); TYPO3.ModuleMenu.App.showModule('web_list', 'id=0&search_levels=4&search_field=' + encodeURIComponent($(searchFieldSelector).val())); }); - $(containerSelector + ' .' + $(searchFieldSelector).autocomplete().options.containerClass).on('click.autocomplete', '.dropdown-list-link', function(evt) { - evt.preventDefault(); - jump($(this).data('target'), 'web_list', 'web', $(this).data('pageid')); - }); + if ($(searchFieldSelector).length) { + $(containerSelector + ' .' + $(searchFieldSelector).autocomplete().options.containerClass).on('click.autocomplete', '.dropdown-list-link', function(evt) { + evt.preventDefault(); + jump($(this).data('target'), 'web_list', 'web', $(this).data('pageid')); + }); + } $(searchFieldSelector).clearable({ onClear: function() { diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/modulemenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/modulemenu.js index c01a76c2ca22..b167087f1930 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/modulemenu.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/modulemenu.js @@ -34,7 +34,9 @@ TYPO3.ModuleMenu.App = { me.showModule(top.startInModule[0], top.startInModule[1]); } else { // fetch first module - me.showModule(TYPO3.jQuery('.t3js-mainmodule:first').attr('id')); + if (TYPO3.jQuery('.t3js-mainmodule:first').length) { + me.showModule(TYPO3.jQuery('.t3js-mainmodule:first').attr('id')); + } } // check if there are collapsed items in the users' configuration -- GitLab