Make WordPress Core

Ticket #39859: 39859.2.diff

File 39859.2.diff, 4.1 KB (added by afercia, 7 years ago)
  • src/wp-includes/js/media/views/modal.js

     
    1717        tagName:  'div',
    1818        template: wp.template('media-modal'),
    1919
    20         attributes: {
    21                 tabindex: 0
    22         },
    23 
    2420        events: {
    2521                'click .media-modal-backdrop, .media-modal-close': 'escapeHandler',
    2622                'keydown': 'keydown'
     
    3228                _.defaults( this.options, {
    3329                        container: document.body,
    3430                        title:     '',
    35                         propagate: true,
    36                         freeze:    true
     31                        propagate: true
    3732                });
    3833
    3934                this.focusManager = new wp.media.view.FocusManager({
     
    8883         */
    8984        open: function() {
    9085                var $el = this.$el,
    91                         options = this.options,
    9286                        mceEditor;
    9387
    9488                if ( $el.is(':visible') ) {
     
    10195                        this.attach();
    10296                }
    10397
    104                 // If the `freeze` option is set, record the window's scroll position.
    105                 if ( options.freeze ) {
    106                         this._freeze = {
    107                                 scrollTop: $( window ).scrollTop()
    108                         };
    109                 }
    110 
    11198                // Disable page scrolling.
    11299                $( 'body' ).addClass( 'modal-open' );
    113100
     
    125112                        }
    126113                }
    127114
    128                 this.$el.focus();
     115                this.$el.find( '.media-modal' ).focus();
    129116
    130117                return this.propagate('open');
    131118        },
     
    135122         * @returns {wp.media.view.Modal} Returns itself to allow chaining
    136123         */
    137124        close: function( options ) {
    138                 var freeze = this._freeze;
    139 
    140125                if ( ! this.views.attached || ! this.$el.is(':visible') ) {
    141126                        return this;
    142127                }
     
    156141
    157142                this.propagate('close');
    158143
    159                 // If the `freeze` option is set, restore the container's scroll position.
    160                 if ( freeze ) {
    161                         $( window ).scrollTop( freeze.scrollTop );
    162                 }
    163 
    164144                if ( options && options.escape ) {
    165145                        this.propagate('escape');
    166146                }
  • src/wp-includes/js/media-views.js

     
    42484248        tagName:  'div',
    42494249        template: wp.template('media-modal'),
    42504250
    4251         attributes: {
    4252                 tabindex: 0
    4253         },
    4254 
    42554251        events: {
    42564252                'click .media-modal-backdrop, .media-modal-close': 'escapeHandler',
    42574253                'keydown': 'keydown'
     
    42634259                _.defaults( this.options, {
    42644260                        container: document.body,
    42654261                        title:     '',
    4266                         propagate: true,
    4267                         freeze:    true
     4262                        propagate: true
    42684263                });
    42694264
    42704265                this.focusManager = new wp.media.view.FocusManager({
     
    43194314         */
    43204315        open: function() {
    43214316                var $el = this.$el,
    4322                         options = this.options,
    43234317                        mceEditor;
    43244318
    43254319                if ( $el.is(':visible') ) {
     
    43324326                        this.attach();
    43334327                }
    43344328
    4335                 // If the `freeze` option is set, record the window's scroll position.
    4336                 if ( options.freeze ) {
    4337                         this._freeze = {
    4338                                 scrollTop: $( window ).scrollTop()
    4339                         };
    4340                 }
    4341 
    43424329                // Disable page scrolling.
    43434330                $( 'body' ).addClass( 'modal-open' );
    43444331
     
    43564343                        }
    43574344                }
    43584345
    4359                 this.$el.focus();
     4346                this.$el.find( '.media-modal' ).focus();
    43604347
    43614348                return this.propagate('open');
    43624349        },
     
    43664353         * @returns {wp.media.view.Modal} Returns itself to allow chaining
    43674354         */
    43684355        close: function( options ) {
    4369                 var freeze = this._freeze;
    4370 
    43714356                if ( ! this.views.attached || ! this.$el.is(':visible') ) {
    43724357                        return this;
    43734358                }
     
    43874372
    43884373                this.propagate('close');
    43894374
    4390                 // If the `freeze` option is set, restore the container's scroll position.
    4391                 if ( freeze ) {
    4392                         $( window ).scrollTop( freeze.scrollTop );
    4393                 }
    4394 
    43954375                if ( options && options.escape ) {
    43964376                        this.propagate('escape');
    43974377                }
  • src/wp-includes/media-template.php

     
    182182        </script>
    183183
    184184        <script type="text/html" id="tmpl-media-modal">
    185                 <div class="<?php echo $class; ?>">
     185                <div tabindex="0" class="<?php echo $class; ?>">
    186186                        <button type="button" class="media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></button>
    187187                        <div class="media-modal-content"></div>
    188188                </div>