Customize: Prevent collapsing expanded panel/section/control when `Esc` is pressed on another closable UI element.
Prevents collapsing constructs when hitting `Esc` on a TinyMCE toolbar, lightbox, or expanded color picker. See #22237. Fixes #38091. Built from https://develop.svn.wordpress.org/trunk@39120 git-svn-id: http://core.svn.wordpress.org/trunk@39060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
32be6f7bb7
commit
ea5f4179a7
|
@ -1123,7 +1123,7 @@
|
|||
section.template = wp.template( 'customize-themes-details-view' );
|
||||
|
||||
// Bind global keyboard events.
|
||||
$( 'body' ).on( 'keyup', function( event ) {
|
||||
section.container.on( 'keydown', function( event ) {
|
||||
if ( ! section.overlay.find( '.theme-wrap' ).is( ':visible' ) ) {
|
||||
return;
|
||||
}
|
||||
|
@ -1141,6 +1141,7 @@
|
|||
// Pressing the escape key fires a theme:collapse event
|
||||
if ( 27 === event.keyCode ) {
|
||||
section.closeDetails();
|
||||
event.stopPropagation(); // Prevent section from being collapsed.
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2864,7 +2865,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
this.setting.bind( function ( value ) {
|
||||
control.setting.bind( function ( value ) {
|
||||
// bail if the update came from the control itself
|
||||
if ( updating ) {
|
||||
return;
|
||||
|
@ -2872,6 +2873,20 @@
|
|||
picker.val( value );
|
||||
picker.wpColorPicker( 'color', value );
|
||||
} );
|
||||
|
||||
// Collapse color picker when hitting Esc instead of collapsing the current section.
|
||||
control.container.on( 'keydown', function( event ) {
|
||||
var pickerContainer;
|
||||
if ( 27 !== event.which ) { // Esc.
|
||||
return;
|
||||
}
|
||||
pickerContainer = control.container.find( '.wp-picker-container' );
|
||||
if ( pickerContainer.hasClass( 'wp-picker-active' ) ) {
|
||||
picker.wpColorPicker( 'close' );
|
||||
control.container.find( '.wp-color-result' ).focus();
|
||||
event.stopPropagation(); // Prevent section from being collapsed.
|
||||
}
|
||||
} );
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -5301,6 +5316,14 @@
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Abort if the event target is not the body (the default) and not inside of #customize-controls.
|
||||
* This ensures that ESC meant to collapse a modal dialog or a TinyMCE toolbar won't collapse something else.
|
||||
*/
|
||||
if ( ! $( event.target ).is( 'body' ) && ! $.contains( $( '#customize-controls' )[0], event.target ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for expanded expandable controls (e.g. widgets and nav menus items), sections, and panels.
|
||||
api.control.each( function( control ) {
|
||||
if ( control.expanded && control.expanded() && _.isFunction( control.collapse ) ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-beta1-39117';
|
||||
$wp_version = '4.7-beta1-39120';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue