WordPress.org

Make WordPress Core

Changeset 39653


Ignore:
Timestamp:
12/30/16 06:12:53 (10 months ago)
Author:
dd32
Message:

Customize: Fix visible edit shortcuts for wp_nav_menu() instances using the menu arg (such as in the Custom Menu widget) instead of the theme_location arg.

Also fix logic for focus-control-for-setting handler to focus on the first control (lowest priority value) associated with a given setting instead of the last control encountered when iterating over all controls, as this ensures the first control in a nav_menu section is focused rather than the last one.

Props westonruter, sirbrillig.
See #27403.
Merges [39622] to the 4.7 branch.
Fixes #39101.

Location:
branches/4.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-admin/js/customize-controls.js

    r39569 r39653  
    53665366        // Focus on the control that is associated with the given setting. 
    53675367        api.previewer.bind( 'focus-control-for-setting', function( settingId ) { 
    5368             var matchedControl; 
     5368            var matchedControls = []; 
    53695369            api.control.each( function( control ) { 
    53705370                var settingIds = _.pluck( control.settings, 'id' ); 
    53715371                if ( -1 !== _.indexOf( settingIds, settingId ) ) { 
    5372                     matchedControl = control; 
     5372                    matchedControls.push( control ); 
    53735373                } 
    53745374            } ); 
    53755375 
    5376             if ( matchedControl ) { 
    5377                 matchedControl.focus(); 
     5376            // Focus on the matched control with the lowest priority (appearing higher). 
     5377            if ( matchedControls.length ) { 
     5378                matchedControls.sort( function( a, b ) { 
     5379                    return a.priority() - b.priority(); 
     5380                } ); 
     5381                matchedControls[0].focus(); 
    53785382            } 
    53795383        } ); 
  • branches/4.7/src/wp-includes/js/customize-selective-refresh.js

    r39606 r39653  
    313313         */ 
    314314        showControl: function() { 
    315             var partial = this, settingId = partial.params.primarySetting, menuSlug; 
     315            var partial = this, settingId = partial.params.primarySetting; 
    316316            if ( ! settingId ) { 
    317317                settingId = _.first( partial.settings() ); 
    318318            } 
    319319            if ( partial.getType() === 'nav_menu' ) { 
    320                 menuSlug = partial.params.navMenuArgs.theme_location; 
    321                 if ( menuSlug ) { 
    322                     settingId = 'nav_menu_locations[' + menuSlug + ']'; 
     320                if ( partial.params.navMenuArgs.theme_location ) { 
     321                    settingId = 'nav_menu_locations[' + partial.params.navMenuArgs.theme_location + ']'; 
     322                } else if ( partial.params.navMenuArgs.menu )   { 
     323                    settingId = 'nav_menu[' + String( partial.params.navMenuArgs.menu ) + ']'; 
    323324                } 
    324325            } 
Note: See TracChangeset for help on using the changeset viewer.