Customize: Ensure that widgets and nav-menus can be closed after entering content.

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
This commit is contained in:
Jake Spurlock 2020-07-13 20:13:49 +00:00
parent 81364742b1
commit c3cdd9c962
2 changed files with 8 additions and 9 deletions

View File

@ -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() { 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() { this.$el.on( 'input', '#custom-menu-item-name.invalid, #custom-menu-item-url.invalid', function() {
@ -733,7 +733,7 @@
$( 'body' ).removeClass( 'adding-menu-items' ); $( 'body' ).removeClass( 'adding-menu-items' );
$( '#available-menu-items .menu-item-handle.item-added' ).removeClass( 'item-added' ); $( '#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. // Add a few keyboard enhancements to the panel.
@ -1819,10 +1819,10 @@
/* /*
* If the menu item deleted is the only of its instance left, * If the menu item deleted is the only of its instance left,
* remove the check icon of this menu item in the right panel. * remove the check icon of this menu item in the right panel.
*/ */
_.each( addedItems, function( addedItem ) { _.each( addedItems, function( addedItem ) {
var menuItemId, menuItemControl, matches; var menuItemId, menuItemControl, matches;
// This is because menu item that's deleted is just hidden. // This is because menu item that's deleted is just hidden.
if ( ! $( addedItem ).is( ':visible' ) ) { if ( ! $( addedItem ).is( ':visible' ) ) {
return; return;

View File

@ -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() { this.$clearResults.on( 'click', function() {
self.$search.val( '' ).focus(); self.$search.val( '' ).focus().trigger( 'input' );
self.collection.doSearch( '' );
} ); } );
// Close the panel if the URL in the preview changes. // Close the panel if the URL in the preview changes.
@ -385,7 +384,7 @@
$( 'body' ).removeClass( 'adding-widget' ); $( 'body' ).removeClass( 'adding-widget' );
this.$search.val( '' ); this.$search.val( '' ).trigger( 'input' );
}, },
/** /**