[BUGFIX] Prevent submitting LiveSearch form 92/44692/2
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 12 Nov 2015 13:13:54 +0000 (14:13 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 12 Nov 2015 14:25:30 +0000 (15:25 +0100)
Hitting enter in the LiveSearch form results in a reload
of the TYPO3 backend. Prevent the submit action with JavaScript.

Resolves: #71481
Releases: master
Change-Id: Ie6fd69d481501d5380cff11fce24dc58ea745e81
Reviewed-on: https://review.typo3.org/44692
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Resources/Public/JavaScript/LiveSearch.js

index 223b5ba..307e889 100644 (file)
@@ -21,6 +21,7 @@ define(['jquery', 'jquery/autocomplete', 'TYPO3/CMS/Backend/jquery.clearable'],
 
        var containerSelector = '#typo3-cms-backend-backend-toolbaritems-livesearchtoolbaritem';
        var searchFieldSelector = '.t3js-topbar-navigation-search-field';
+       var formSelector = '.t3js-topbar-navigation-search';
        var url = TYPO3.settings.ajaxUrls['livesearch'];
        var category = '';
 
@@ -97,9 +98,14 @@ define(['jquery', 'jquery/autocomplete', 'TYPO3/CMS/Backend/jquery.clearable'],
                });
 
                $(searchFieldSelector).clearable({
-                               onClear: function() {
-                                       $(containerSelector).removeClass('open');
-                               }
+                       onClear: function() {
+                               $(containerSelector).removeClass('open');
+                       }
+               });
+
+               // Prevent submitting the search form
+               $(formSelector).submit(function(evt) {
+                       evt.preventDefault();
                });
        });