Make WordPress Core

Changeset 38668


Ignore:
Timestamp:
09/28/2016 04:19:37 AM (7 years ago)
Author:
westonruter
Message:

Customize: Fix focusing on controls for widgets and nav menu items after [38648].

Shift-click on nav menu items was not expanding the nav menu section, and shift-clicking on widgets would not always result in focus being added to an element in the control's container.

See #34391.

Location:
trunk/src/wp-admin/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-nav-menus.js

    r38648 r38668  
    15301530        expandControlSection: function() {
    15311531            var $section = this.container.closest( '.accordion-section' );
    1532 
    15331532            if ( ! $section.hasClass( 'open' ) ) {
    15341533                $section.find( '.accordion-section-title:first' ).trigger( 'click' );
     
    16841683        focus: function( params ) {
    16851684            params = params || {};
    1686             var control = this, originalCompleteCallback = params.completeCallback;
    1687 
    1688             control.expandControlSection();
    1689 
    1690             params.completeCallback = function() {
    1691                 var focusable;
    1692 
    1693                 // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
    1694                 focusable = control.container.find( '.menu-item-settings' ).find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' );
    1695                 focusable.first().focus();
    1696 
    1697                 if ( originalCompleteCallback ) {
    1698                     originalCompleteCallback();
    1699                 }
     1685            var control = this, originalCompleteCallback = params.completeCallback, focusControl;
     1686
     1687            focusControl = function() {
     1688                control.expandControlSection();
     1689
     1690                params.completeCallback = function() {
     1691                    var focusable;
     1692
     1693                    // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
     1694                    focusable = control.container.find( '.menu-item-settings' ).find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' );
     1695                    focusable.first().focus();
     1696
     1697                    if ( originalCompleteCallback ) {
     1698                        originalCompleteCallback();
     1699                    }
     1700                };
     1701
     1702                control.expandForm( params );
    17001703            };
    17011704
    1702             control.expandForm( params );
     1705            if ( api.section.has( control.section() ) ) {
     1706                api.section( control.section() ).expand( {
     1707                    completeCallback: focusControl
     1708                } );
     1709            } else {
     1710                focusControl();
     1711            }
    17031712        },
    17041713
     
    29562965    api.Menus.focusMenuItemControl = function( menuItemId ) {
    29572966        var control = api.Menus.getMenuItemControl( menuItemId );
    2958 
    29592967        if ( control ) {
    29602968            control.focus();
  • trunk/src/wp-admin/js/customize-widgets.js

    r37994 r38668  
    13261326         */
    13271327        onChangeExpanded: function ( expanded, args ) {
    1328             var self = this, $widget, $inside, complete, prevComplete;
     1328            var self = this, $widget, $inside, complete, prevComplete, expandControl;
    13291329
    13301330            self.embedWidgetControl(); // Make sure the outer form is embedded so that the expanded state can be set in the UI.
     
    13461346            $inside = $widget.find( '.widget-inside:first' );
    13471347
    1348             if ( expanded ) {
    1349 
    1350                 if ( self.section() && api.section( self.section() ) ) {
    1351                     self.expandControlSection();
    1352                 }
     1348            expandControl = function() {
    13531349
    13541350                // Close all other widget controls before expanding this one
     
    13801376                self.container.trigger( 'expand' );
    13811377                self.container.addClass( 'expanding' );
     1378            };
     1379
     1380            if ( expanded ) {
     1381                if ( api.section.has( self.section() ) ) {
     1382                    api.section( self.section() ).expand( {
     1383                        completeCallback: expandControl
     1384                    } );
     1385                } else {
     1386                    expandControl();
     1387                }
    13821388            } else {
    13831389
Note: See TracChangeset for help on using the changeset viewer.