From 4361679826c83050f5d7b49b050124973308a741 Mon Sep 17 00:00:00 2001 From: Wouter Wolters <typo3@wouterwolters.nl> Date: Thu, 24 Sep 2015 22:40:35 +0200 Subject: [PATCH] [TASK] Clear button in BE search missing Resolves: #68366 Releases: master Change-Id: I2ad5683d27448c5100c0deb9b9a1be5a1565a919 Reviewed-on: http://review.typo3.org/43542 Reviewed-by: Daniel Goerz <ervaude@gmail.com> Tested-by: Daniel Goerz <ervaude@gmail.com> Reviewed-by: Andreas Fernandez <typo3@scripting-base.de> Tested-by: Andreas Fernandez <typo3@scripting-base.de> --- .../Public/JavaScript/ToggleSearchToolbox.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js b/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js index 97562932ac27..7acca7f05cf6 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js @@ -11,7 +11,7 @@ * The TYPO3 project - inspiring people to share! */ -define('TYPO3/CMS/Backend/ToggleSearchToolbox', ['jquery'], function($) { +define('TYPO3/CMS/Backend/ToggleSearchToolbox', ['jquery', 'TYPO3/CMS/Backend/jquery.clearable'], function($) { $(document).ready(function() { var $toolbar = $('#db_list-searchbox-toolbar'); $('.t3js-toggle-search-toolbox').on('click', function() { @@ -21,5 +21,19 @@ define('TYPO3/CMS/Backend/ToggleSearchToolbox', ['jquery'], function($) { $('#search_field').focus(); } }); + + var $searchFields = $('#search_field'); + var searchResultShown = ('' !== $searchFields.val()); + + // make search field clearable + $searchFields.clearable( + { + onClear: function() { + if (searchResultShown) { + $(this).closest('form').submit(); + } + } + } + ); }); -}); +}); \ No newline at end of file -- GitLab