From 79439329638eeefa39d33329d0e0547f6a3b22b5 Mon Sep 17 00:00:00 2001 From: Deepak Kumar Date: Fri, 9 Oct 2026 21:31:06 +0530 Subject: [PATCH 1/2] Media: Place dialog Close and navigation buttons after the heading in the DOM --- src/js/media/views/media-frame.js | 6 ++++-- src/wp-includes/media-template.php | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/js/media/views/media-frame.js b/src/js/media/views/media-frame.js index 9d99f3a5e81a9..c0221cfe03f97 100644 --- a/src/js/media/views/media-frame.js +++ b/src/js/media/views/media-frame.js @@ -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 }); this.modal.content( this ); diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index ee9c6bc21a1c3..d074f6ebde996 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -179,6 +179,14 @@ function wp_print_media_templates() { From cba6917e33b0bcef0f20ebf8439ed50bb851d3b4 Mon Sep 17 00:00:00 2001 From: Deepak Kumar Date: Fri, 9 Oct 2026 21:31:09 +0530 Subject: [PATCH 2/2] Widgets: Keep gallery widget initial focus off the media modal Close button --- src/js/_enqueues/wp/widgets/media-gallery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/_enqueues/wp/widgets/media-gallery.js b/src/js/_enqueues/wp/widgets/media-gallery.js index fe9f93cb381db..b90de2ddfbe88 100644 --- a/src/js/_enqueues/wp/widgets/media-gallery.js +++ b/src/js/_enqueues/wp/widgets/media-gallery.js @@ -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(); }, /**