Make WordPress Core

Changeset 37152


Ignore:
Timestamp:
03/30/2016 09:40:43 PM (8 years ago)
Author:
westonruter
Message:

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.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r36866 r37152  
    7878     */
    7979    focus = function ( params ) {
    80         var construct, completeCallback, focus;
     80        var construct, completeCallback, focus, focusElement;
    8181        construct = this;
    8282        params = params || {};
     
    9191            }
    9292
    93             // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
    94             focusContainer.find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ).first().focus();
     93            focusElement = focusContainer.find( '.control-focus:first' );
     94            if ( 0 === focusElement.length ) {
     95                // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583
     96                focusElement = focusContainer.find( 'input, select, textarea, button, object, a[href], [tabindex]' ).filter( ':visible' ).first();
     97            }
     98            focusElement.focus();
    9599        };
    96100        if ( params.completeCallback ) {
  • trunk/src/wp-includes/customize/class-wp-customize-media-control.php

    r36769 r37152  
    197197                <# if ( data.canUpload ) { #>
    198198                <button type="button" class="button remove-button">{{ data.button_labels.remove }}</button>
    199                 <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button">{{ data.button_labels.change }}</button>
     199                <button type="button" class="button upload-button control-focus" id="{{ data.settings['default'] }}-button">{{ data.button_labels.change }}</button>
    200200                <div style="clear:both"></div>
    201201                <# } #>
Note: See TracChangeset for help on using the changeset viewer.