Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js/_enqueues/wp/widgets/media-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@
* Make sure focus is set inside of modal so that hitting Esc will close
* the modal and not inadvertently cause the widget to collapse in the customizer.
*/
mediaFrame.$el.find( ':focusable:first' ).focus();
mediaFrame.$el.find( ':focusable:not(.media-modal-close):first' ).focus();
},

/**
Expand Down
6 changes: 4 additions & 2 deletions src/js/media/views/media-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ MediaFrame = Frame.extend(/** @lends wp.media.view.MediaFrame.prototype */{

// Initialize modal container view.
if ( this.options.modal ) {
// The frame renders its own close button after the title, see `tmpl-media-frame`.
this.modal = new wp.media.view.Modal({
controller: this,
title: this.options.title
controller: this,
title: this.options.title,
hasCloseButton: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding:

Back-compat: a plugin that overrides tmpl-media-frame would no longer get a Close button in the modal.

Is there any way to mitigate this risk? To my understanding:

  • If the frame modal option is true, it will now use the button in the correct order
  • If the frame modal option is false (is this the case when the frame may be overridden by plugins?) then let the button in the wrong order be used. It will be wrong order, but at least there is no backward compatibility breakage.

I may be missing something though.

});

this.modal.content( this );
Expand Down
10 changes: 9 additions & 1 deletion src/wp-includes/media-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ function wp_print_media_templates() {
<?php // Template for the media frame: used both in the media grid and in the media modal. ?>
<script type="text/html" id="tmpl-media-frame">
<div class="media-frame-title"></div>
<# if ( data.modal ) { #>
<button type="button" class="media-modal-close"><span class="media-modal-icon" aria-hidden="true"></span><span class="screen-reader-text">
<?php
/* translators: Hidden accessibility text. */
_e( 'Close' );
?>
</span></button>
<# } #>
<h2 class="media-frame-menu-heading"><?php _ex( 'Actions', 'media modal menu actions' ); ?></h2>
<button type="button" class="button button-link media-frame-menu-toggle" aria-expanded="false">
<?php _ex( 'Menu', 'media modal menu' ); ?>
Expand Down Expand Up @@ -368,12 +376,12 @@ function wp_print_media_templates() {

<?php // Template for the Attachment Details layout in the media browser. ?>
<script type="text/html" id="tmpl-edit-attachment-frame">
<div class="media-frame-title"></div>
<div class="edit-media-header">
<button class="left dashicons"<# if ( ! data.hasPrevious ) { #> aria-disabled='true'<# } #>><span class="screen-reader-text"><?php /* translators: Hidden accessibility text. */ _ex( 'Previous', 'media item' ); ?></span></button>
<button class="right dashicons"<# if ( ! data.hasNext ) { #> aria-disabled='true'<# } #>><span class="screen-reader-text"><?php /* translators: Hidden accessibility text. */ _ex( 'Next', 'media item' ); ?></span></button>
<button type="button" class="media-modal-close"><span class="media-modal-icon" aria-hidden="true"></span><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button>
</div>
<div class="media-frame-title"></div>
<div class="media-frame-content"></div>
</script>

Expand Down
Loading