Make WordPress Core

Ticket #38091: 38091.0.diff

File 38091.0.diff, 1.9 KB (added by westonruter, 9 years ago)
  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index 7078cfd..6891acc 100644
     
    808808                        section.template = wp.template( 'customize-themes-details-view' );
    809809
    810810                        // Bind global keyboard events.
    811                         $( 'body' ).on( 'keyup', function( event ) {
     811                        section.container.on( 'keydown', function( event ) {
    812812                                if ( ! section.overlay.find( '.theme-wrap' ).is( ':visible' ) ) {
    813813                                        return;
    814814                                }
     
    826826                                // Pressing the escape key fires a theme:collapse event
    827827                                if ( 27 === event.keyCode ) {
    828828                                        section.closeDetails();
     829                                        event.stopPropagation(); // Prevent section from being collapsed.
    829830                                }
    830831                        });
    831832
     
    18901891                                picker.val( value );
    18911892                                picker.wpColorPicker( 'color', value );
    18921893                        });
     1894
     1895                        control.container.on( 'keydown', function( event ) {
     1896                                var pickerContainer;
     1897                                if ( 27 !== event.which ) { // Esc.
     1898                                        return;
     1899                                }
     1900                                pickerContainer = control.container.find( '.wp-picker-container' );
     1901                                if ( pickerContainer.hasClass( 'wp-picker-active' ) ) {
     1902                                        picker.wpColorPicker( 'close' );
     1903                                        control.container.find( '.wp-color-result' ).focus();
     1904                                        event.stopPropagation(); // Prevent section from being collapsed.
     1905                                }
     1906                        } );
    18931907                }
    18941908        });
    18951909
     
    40024016                                return;
    40034017                        }
    40044018
     4019                        /*
     4020                         * Abort if the event target is not the body (the default) and not inside of #customize-controls.
     4021                         * This ensures that ESC meant to collapse a modal dialog or a TinyMCE toolbar won't collapse something else.
     4022                         */
     4023                        if ( ! $( event.target ).is( 'body' ) && ! $.contains( $( '#customize-controls' )[0], event.target ) ) {
     4024                                return;
     4025                        }
     4026
    40054027                        // Check for expanded expandable controls (e.g. widgets and nav menus items), sections, and panels.
    40064028                        api.control.each( function( control ) {
    40074029                                if ( control.expanded && control.expanded() && _.isFunction( control.collapse ) ) {