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. git-svn-id: https://develop.svn.wordpress.org/trunk@38668 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
81ecd4da98
commit
c286c27747
@ -1529,7 +1529,6 @@
|
|||||||
*/
|
*/
|
||||||
expandControlSection: function() {
|
expandControlSection: function() {
|
||||||
var $section = this.container.closest( '.accordion-section' );
|
var $section = this.container.closest( '.accordion-section' );
|
||||||
|
|
||||||
if ( ! $section.hasClass( 'open' ) ) {
|
if ( ! $section.hasClass( 'open' ) ) {
|
||||||
$section.find( '.accordion-section-title:first' ).trigger( 'click' );
|
$section.find( '.accordion-section-title:first' ).trigger( 'click' );
|
||||||
}
|
}
|
||||||
@ -1683,23 +1682,33 @@
|
|||||||
*/
|
*/
|
||||||
focus: function( params ) {
|
focus: function( params ) {
|
||||||
params = 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() {
|
params.completeCallback = function() {
|
||||||
var focusable;
|
var focusable;
|
||||||
|
|
||||||
// Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
|
// 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 = control.container.find( '.menu-item-settings' ).find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' );
|
||||||
focusable.first().focus();
|
focusable.first().focus();
|
||||||
|
|
||||||
if ( originalCompleteCallback ) {
|
if ( originalCompleteCallback ) {
|
||||||
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 ) {
|
api.Menus.focusMenuItemControl = function( menuItemId ) {
|
||||||
var control = api.Menus.getMenuItemControl( menuItemId );
|
var control = api.Menus.getMenuItemControl( menuItemId );
|
||||||
|
|
||||||
if ( control ) {
|
if ( control ) {
|
||||||
control.focus();
|
control.focus();
|
||||||
}
|
}
|
||||||
|
@ -1325,7 +1325,7 @@
|
|||||||
* @param {Object} args merged on top of this.defaultActiveArguments
|
* @param {Object} args merged on top of this.defaultActiveArguments
|
||||||
*/
|
*/
|
||||||
onChangeExpanded: function ( expanded, args ) {
|
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.
|
self.embedWidgetControl(); // Make sure the outer form is embedded so that the expanded state can be set in the UI.
|
||||||
if ( expanded ) {
|
if ( expanded ) {
|
||||||
@ -1345,11 +1345,7 @@
|
|||||||
$widget = this.container.find( 'div.widget:first' );
|
$widget = this.container.find( 'div.widget:first' );
|
||||||
$inside = $widget.find( '.widget-inside:first' );
|
$inside = $widget.find( '.widget-inside:first' );
|
||||||
|
|
||||||
if ( expanded ) {
|
expandControl = function() {
|
||||||
|
|
||||||
if ( self.section() && api.section( self.section() ) ) {
|
|
||||||
self.expandControlSection();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close all other widget controls before expanding this one
|
// Close all other widget controls before expanding this one
|
||||||
api.control.each( function( otherControl ) {
|
api.control.each( function( otherControl ) {
|
||||||
@ -1379,6 +1375,16 @@
|
|||||||
|
|
||||||
self.container.trigger( 'expand' );
|
self.container.trigger( 'expand' );
|
||||||
self.container.addClass( 'expanding' );
|
self.container.addClass( 'expanding' );
|
||||||
|
};
|
||||||
|
|
||||||
|
if ( expanded ) {
|
||||||
|
if ( api.section.has( self.section() ) ) {
|
||||||
|
api.section( self.section() ).expand( {
|
||||||
|
completeCallback: expandControl
|
||||||
|
} );
|
||||||
|
} else {
|
||||||
|
expandControl();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
complete = function() {
|
complete = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user