Make WordPress Core

Ticket #39859: 39859.diff

File 39859.diff, 3.8 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({
     
    10196                        this.attach();
    10297                }
    10398
    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 
    11199                // Disable page scrolling.
    112100                $( 'body' ).addClass( 'modal-open' );
    113101
     
    125113                        }
    126114                }
    127115
    128                 this.$el.focus();
     116                this.$el.find( '.media-modal' ).focus();
    129117
    130118                return this.propagate('open');
    131119        },
     
    135123         * @returns {wp.media.view.Modal} Returns itself to allow chaining
    136124         */
    137125        close: function( options ) {
    138                 var freeze = this._freeze;
    139 
    140126                if ( ! this.views.attached || ! this.$el.is(':visible') ) {
    141127                        return this;
    142128                }
     
    156142
    157143                this.propagate('close');
    158144
    159                 // If the `freeze` option is set, restore the container's scroll position.
    160                 if ( freeze ) {
    161                         $( window ).scrollTop( freeze.scrollTop );
    162                 }
    163 
    164145                if ( options && options.escape ) {
    165146                        this.propagate('escape');
    166147                }
  • src/wp-includes/js/media-views.js

     
    41734173        tagName:  'div',
    41744174        template: wp.template('media-modal'),
    41754175
    4176         attributes: {
    4177                 tabindex: 0
    4178         },
    4179 
    41804176        events: {
    41814177                'click .media-modal-backdrop, .media-modal-close': 'escapeHandler',
    41824178                'keydown': 'keydown'
     
    41884184                _.defaults( this.options, {
    41894185                        container: document.body,
    41904186                        title:     '',
    4191                         propagate: true,
    4192                         freeze:    true
     4187                        propagate: true
    41934188                });
    41944189
    41954190                this.focusManager = new wp.media.view.FocusManager({
     
    42574252                        this.attach();
    42584253                }
    42594254
    4260                 // If the `freeze` option is set, record the window's scroll position.
    4261                 if ( options.freeze ) {
    4262                         this._freeze = {
    4263                                 scrollTop: $( window ).scrollTop()
    4264                         };
    4265                 }
    4266 
    42674255                // Disable page scrolling.
    42684256                $( 'body' ).addClass( 'modal-open' );
    42694257
     
    42814269                        }
    42824270                }
    42834271
    4284                 this.$el.focus();
     4272                this.$el.find( '.media-modal' ).focus();
    42854273
    42864274                return this.propagate('open');
    42874275        },
     
    42914279         * @returns {wp.media.view.Modal} Returns itself to allow chaining
    42924280         */
    42934281        close: function( options ) {
    4294                 var freeze = this._freeze;
    4295 
    42964282                if ( ! this.views.attached || ! this.$el.is(':visible') ) {
    42974283                        return this;
    42984284                }
     
    43124298
    43134299                this.propagate('close');
    43144300
    4315                 // If the `freeze` option is set, restore the container's scroll position.
    4316                 if ( freeze ) {
    4317                         $( window ).scrollTop( freeze.scrollTop );
    4318                 }
    4319 
    43204301                if ( options && options.escape ) {
    43214302                        this.propagate('escape');
    43224303                }
  • src/wp-includes/media-template.php

     
    162162        </script>
    163163
    164164        <script type="text/html" id="tmpl-media-modal">
    165                 <div class="<?php echo $class; ?>">
     165                <div tabindex="0" class="<?php echo $class; ?>">
    166166                        <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>
    167167                        <div class="media-modal-content"></div>
    168168                </div>