From 99dde2673060c889e57ed4cab03341dc4fa43257 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Fri, 19 May 2017 17:26:06 +0000 Subject: [PATCH] Dashboard: Don't trigger an Events search when the search field is empty. Fixes #40816. git-svn-id: https://develop.svn.wordpress.org/trunk@40799 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/dashboard.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/js/dashboard.js b/src/wp-admin/js/dashboard.js index bb46173660..71d0a18f1b 100644 --- a/src/wp-admin/js/dashboard.js +++ b/src/wp-admin/js/dashboard.js @@ -234,10 +234,20 @@ jQuery( function( $ ) { $container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm ); $container.on( 'submit', '.community-events-form', function( event ) { + var location = $.trim( $( '#community-events-location' ).val() ); + event.preventDefault(); + /* + * Don't trigger a search if the search field is empty or the + * search term was made of only spaces before being trimmed. + */ + if ( ! location ) { + return; + } + app.getEvents({ - location: $( '#community-events-location' ).val() + location: location }); });