diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 95db551a68..3287b73762 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -4248,10 +4248,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ tagName: 'div', template: wp.template('media-modal'), - attributes: { - tabindex: 0 - }, - events: { 'click .media-modal-backdrop, .media-modal-close': 'escapeHandler', 'keydown': 'keydown' @@ -4263,8 +4259,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ _.defaults( this.options, { container: document.body, title: '', - propagate: true, - freeze: true + propagate: true }); this.focusManager = new wp.media.view.FocusManager({ @@ -4319,7 +4314,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ */ open: function() { var $el = this.$el, - options = this.options, mceEditor; if ( $el.is(':visible') ) { @@ -4332,13 +4326,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ this.attach(); } - // If the `freeze` option is set, record the window's scroll position. - if ( options.freeze ) { - this._freeze = { - scrollTop: $( window ).scrollTop() - }; - } - // Disable page scrolling. $( 'body' ).addClass( 'modal-open' ); @@ -4346,7 +4333,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ // Try to close the onscreen keyboard if ( 'ontouchend' in document ) { - if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) { + if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) { mceEditor.iframeElement.focus(); mceEditor.iframeElement.blur(); @@ -4356,7 +4343,8 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ } } - this.$el.focus(); + // Set initial focus on the content instead of this view element, to avoid page scrolling. + this.$( '.media-modal' ).focus(); return this.propagate('open'); }, @@ -4366,8 +4354,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ * @returns {wp.media.view.Modal} Returns itself to allow chaining */ close: function( options ) { - var freeze = this._freeze; - if ( ! this.views.attached || ! this.$el.is(':visible') ) { return this; } @@ -4387,11 +4373,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ this.propagate('close'); - // If the `freeze` option is set, restore the container's scroll position. - if ( freeze ) { - $( window ).scrollTop( freeze.scrollTop ); - } - if ( options && options.escape ) { this.propagate('escape'); } diff --git a/src/wp-includes/js/media/views/modal.js b/src/wp-includes/js/media/views/modal.js index f31a59d6d4..48150b74ec 100644 --- a/src/wp-includes/js/media/views/modal.js +++ b/src/wp-includes/js/media/views/modal.js @@ -17,10 +17,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ tagName: 'div', template: wp.template('media-modal'), - attributes: { - tabindex: 0 - }, - events: { 'click .media-modal-backdrop, .media-modal-close': 'escapeHandler', 'keydown': 'keydown' @@ -32,8 +28,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ _.defaults( this.options, { container: document.body, title: '', - propagate: true, - freeze: true + propagate: true }); this.focusManager = new wp.media.view.FocusManager({ @@ -88,7 +83,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ */ open: function() { var $el = this.$el, - options = this.options, mceEditor; if ( $el.is(':visible') ) { @@ -101,13 +95,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ this.attach(); } - // If the `freeze` option is set, record the window's scroll position. - if ( options.freeze ) { - this._freeze = { - scrollTop: $( window ).scrollTop() - }; - } - // Disable page scrolling. $( 'body' ).addClass( 'modal-open' ); @@ -115,7 +102,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ // Try to close the onscreen keyboard if ( 'ontouchend' in document ) { - if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) { + if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) { mceEditor.iframeElement.focus(); mceEditor.iframeElement.blur(); @@ -125,7 +112,8 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ } } - this.$el.focus(); + // Set initial focus on the content instead of this view element, to avoid page scrolling. + this.$( '.media-modal' ).focus(); return this.propagate('open'); }, @@ -135,8 +123,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ * @returns {wp.media.view.Modal} Returns itself to allow chaining */ close: function( options ) { - var freeze = this._freeze; - if ( ! this.views.attached || ! this.$el.is(':visible') ) { return this; } @@ -156,11 +142,6 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ this.propagate('close'); - // If the `freeze` option is set, restore the container's scroll position. - if ( freeze ) { - $( window ).scrollTop( freeze.scrollTop ); - } - if ( options && options.escape ) { this.propagate('escape'); } diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 4f2f302e0e..0dbba580f4 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -182,7 +182,7 @@ function wp_print_media_templates() {