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.

Built from https://develop.svn.wordpress.org/trunk@38668


git-svn-id: http://core.svn.wordpress.org/trunk@38611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-09-28 04:20:29 +00:00
parent 3b6314e032
commit 9a9af068e5
5 changed files with 37 additions and 23 deletions

View File

@ -1529,7 +1529,6 @@
*/
expandControlSection: function() {
var $section = this.container.closest( '.accordion-section' );
if ( ! $section.hasClass( 'open' ) ) {
$section.find( '.accordion-section-title:first' ).trigger( 'click' );
}
@ -1683,23 +1682,33 @@
*/
focus: function( params ) {
params = params || {};
var control = this, originalCompleteCallback = params.completeCallback;
var control = this, originalCompleteCallback = params.completeCallback, focusControl;
control.expandControlSection();
focusControl = function() {
control.expandControlSection();
params.completeCallback = function() {
var focusable;
params.completeCallback = function() {
var focusable;
// Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
focusable = control.container.find( '.menu-item-settings' ).find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' );
focusable.first().focus();
// Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
focusable = control.container.find( '.menu-item-settings' ).find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' );
focusable.first().focus();
if ( originalCompleteCallback ) {
originalCompleteCallback();
}
if ( originalCompleteCallback ) {
originalCompleteCallback();
}
};
control.expandForm( params );
};
control.expandForm( params );
if ( api.section.has( control.section() ) ) {
api.section( control.section() ).expand( {
completeCallback: focusControl
} );
} else {
focusControl();
}
},
/**
@ -2955,7 +2964,6 @@
*/
api.Menus.focusMenuItemControl = function( menuItemId ) {
var control = api.Menus.getMenuItemControl( menuItemId );
if ( control ) {
control.focus();
}

File diff suppressed because one or more lines are too long

View File

@ -1325,7 +1325,7 @@
* @param {Object} args merged on top of this.defaultActiveArguments
*/
onChangeExpanded: function ( expanded, args ) {
var self = this, $widget, $inside, complete, prevComplete;
var self = this, $widget, $inside, complete, prevComplete, expandControl;
self.embedWidgetControl(); // Make sure the outer form is embedded so that the expanded state can be set in the UI.
if ( expanded ) {
@ -1345,11 +1345,7 @@
$widget = this.container.find( 'div.widget:first' );
$inside = $widget.find( '.widget-inside:first' );
if ( expanded ) {
if ( self.section() && api.section( self.section() ) ) {
self.expandControlSection();
}
expandControl = function() {
// Close all other widget controls before expanding this one
api.control.each( function( otherControl ) {
@ -1379,6 +1375,16 @@
self.container.trigger( 'expand' );
self.container.addClass( 'expanding' );
};
if ( expanded ) {
if ( api.section.has( self.section() ) ) {
api.section( self.section() ).expand( {
completeCallback: expandControl
} );
} else {
expandControl();
}
} else {
complete = function() {

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38667';
$wp_version = '4.7-alpha-38668';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.