diff --git a/src/js/media/views/attachments.js b/src/js/media/views/attachments.js index b2e91624cb159..0d90c720d9844 100644 --- a/src/js/media/views/attachments.js +++ b/src/js/media/views/attachments.js @@ -8,6 +8,7 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ className: 'attachments', attributes: { + role: 'group', tabIndex: -1 }, diff --git a/src/js/media/views/media-frame.js b/src/js/media/views/media-frame.js index 1140bf2795ff4..afdacf5a2102e 100644 --- a/src/js/media/views/media-frame.js +++ b/src/js/media/views/media-frame.js @@ -158,9 +158,11 @@ MediaFrame = Frame.extend(/** @lends wp.media.view.MediaFrame.prototype */{ * @this wp.media.controller.Region */ createTitle: function( title ) { + // A modal's dialog element points `aria-labelledby` at its frame heading. title.view = new wp.media.View({ controller: this, - tagName: 'h1' + tagName: 'h1', + attributes: this.modal ? { id: this.modal.titleId } : {} }); }, /** diff --git a/src/js/media/views/modal.js b/src/js/media/views/modal.js index 29150515a45cd..c8da850c1246f 100644 --- a/src/js/media/views/modal.js +++ b/src/js/media/views/modal.js @@ -32,6 +32,8 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ hasCloseButton: true }); + this.titleId = _.uniqueId( 'media-frame-title-' ); + this.focusManager = new wp.media.view.FocusManager({ el: this.el }); @@ -39,12 +41,15 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ /** * Prepares the data for the modal template. * + * @since 7.2.0 Added the `titleId` property. + * * @return {Object} The prepared data. */ prepare: function() { return { title: this.options.title, - hasCloseButton: this.options.hasCloseButton + hasCloseButton: this.options.hasCloseButton, + titleId: this.titleId }; }, diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php index 460cf3b3020e5..70e75e0d28567 100644 --- a/src/wp-includes/media-template.php +++ b/src/wp-includes/media-template.php @@ -178,7 +178,7 @@ function wp_print_media_templates() {