Customize: Put focus on change button instead of remove button in media control.

Allow controls to specify the primary element to receive focus by adding a `control-focus` class.

Props adamsilverstein, westonruter.
Fixes #36337.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-03-30 21:41:26 +00:00
parent 328b4aff92
commit 1a9fda07a4
4 changed files with 11 additions and 7 deletions

View File

@ -77,7 +77,7 @@
* @param {Function} [params.completeCallback]
*/
focus = function ( params ) {
var construct, completeCallback, focus;
var construct, completeCallback, focus, focusElement;
construct = this;
params = params || {};
focus = function () {
@ -90,8 +90,12 @@
focusContainer = construct.container;
}
// Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
focusContainer.find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ).first().focus();
focusElement = focusContainer.find( '.control-focus:first' );
if ( 0 === focusElement.length ) {
// Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
focusElement = focusContainer.find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ).first();
}
focusElement.focus();
};
if ( params.completeCallback ) {
completeCallback = params.completeCallback;

File diff suppressed because one or more lines are too long

View File

@ -196,7 +196,7 @@ class WP_Customize_Media_Control extends WP_Customize_Control {
<div class="actions">
<# if ( data.canUpload ) { #>
<button type="button" class="button remove-button">{{ data.button_labels.remove }}</button>
<button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button">{{ data.button_labels.change }}</button>
<button type="button" class="button upload-button control-focus" id="{{ data.settings['default'] }}-button">{{ data.button_labels.change }}</button>
<div style="clear:both"></div>
<# } #>
</div>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-RC1-37150';
$wp_version = '4.5-RC1-37152';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.