From c3cdd9c9627dd0a1600152915904d9a93dfb7db7 Mon Sep 17 00:00:00 2001 From: Jake Spurlock Date: Mon, 13 Jul 2020 20:13:49 +0000 Subject: [PATCH] Customize: Ensure that widgets and nav-menus can be closed after entering content. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the ⌧ button would close the search panel, or remove the results. This restores that, in addition pressing escape will do the same. Fixes #48198. Props garrett-eclipse, tobifjellner, afercia, JavierCasares. git-svn-id: https://develop.svn.wordpress.org/trunk@48461 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/wp/customize/nav-menus.js | 10 +++++----- src/js/_enqueues/wp/customize/widgets.js | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/js/_enqueues/wp/customize/nav-menus.js b/src/js/_enqueues/wp/customize/nav-menus.js index abf8b8bf8a..8e35f68b90 100644 --- a/src/js/_enqueues/wp/customize/nav-menus.js +++ b/src/js/_enqueues/wp/customize/nav-menus.js @@ -216,9 +216,9 @@ } } ); - // Clear the search results and trigger a `keyup` event to fire a new search. + // Clear the search results and trigger an `input` event to fire a new search. this.$clearResults.on( 'click', function() { - self.$search.val( '' ).focus().trigger( 'keyup' ); + self.$search.val( '' ).focus().trigger( 'input' ); } ); this.$el.on( 'input', '#custom-menu-item-name.invalid, #custom-menu-item-url.invalid', function() { @@ -733,7 +733,7 @@ $( 'body' ).removeClass( 'adding-menu-items' ); $( '#available-menu-items .menu-item-handle.item-added' ).removeClass( 'item-added' ); - this.$search.val( '' ).trigger( 'keyup' ); + this.$search.val( '' ).trigger( 'input' ); }, // Add a few keyboard enhancements to the panel. @@ -1819,10 +1819,10 @@ /* * If the menu item deleted is the only of its instance left, * remove the check icon of this menu item in the right panel. - */ + */ _.each( addedItems, function( addedItem ) { var menuItemId, menuItemControl, matches; - + // This is because menu item that's deleted is just hidden. if ( ! $( addedItem ).is( ':visible' ) ) { return; diff --git a/src/js/_enqueues/wp/customize/widgets.js b/src/js/_enqueues/wp/customize/widgets.js index 4c91944b5d..a4266b08d7 100644 --- a/src/js/_enqueues/wp/customize/widgets.js +++ b/src/js/_enqueues/wp/customize/widgets.js @@ -193,10 +193,9 @@ } } ); - // Clear the search results and trigger a new search. + // Clear the search results and trigger an `input` event to fire a new search. this.$clearResults.on( 'click', function() { - self.$search.val( '' ).focus(); - self.collection.doSearch( '' ); + self.$search.val( '' ).focus().trigger( 'input' ); } ); // Close the panel if the URL in the preview changes. @@ -385,7 +384,7 @@ $( 'body' ).removeClass( 'adding-widget' ); - this.$search.val( '' ); + this.$search.val( '' ).trigger( 'input' ); }, /**