Accessibility: Improve the Media Library inline uploader accessibility.
For better accessibility, expandable panels should be placed immediately after the control that expands them. This change moves the Media Library inline uploader up, right after the "Add New" button, also introducing consistency with the Plugin and Theme uploaders. Adds a proper ARIA role on the button and an `aria-expanded` attribute to give better feedback to assistive technologies users about the uploader's expanded state. Improves the focus handling when closing the uploader, improves the focus style and color contrast ratio of the uploader "close" button. Props mantismamita, karmatosed, adamsilverstein, afercia. Fixes #37188. git-svn-id: https://develop.svn.wordpress.org/trunk@40359 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fadd7cb721
commit
9b0de1429d
@ -469,7 +469,7 @@ border color while dragging a file over the uploader drop area */
|
||||
.upload-php .mode-grid .media-sidebar {
|
||||
position: relative;
|
||||
width: auto;
|
||||
margin-bottom: 16px;
|
||||
margin-top: 12px;
|
||||
padding: 0 16px;
|
||||
border-left: 4px solid #dd3d36;
|
||||
-webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
|
||||
@ -526,7 +526,7 @@ border color while dragging a file over the uploader drop area */
|
||||
left: auto;
|
||||
bottom: auto;
|
||||
padding-top: 0;
|
||||
margin-top: 0;
|
||||
margin-top: 20px;
|
||||
border: 4px dashed #b4b9be;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ if ( 'grid' === $mode ) {
|
||||
|
||||
<?php
|
||||
if ( current_user_can( 'upload_files' ) ) { ?>
|
||||
<a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a><?php
|
||||
<a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action aria-button-if-js"><?php echo esc_html_x( 'Add New', 'file' ); ?></a><?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -1133,20 +1133,29 @@
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
height: 48px;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
right: 2px;
|
||||
text-align: center;
|
||||
top: 0;
|
||||
width: 50px;
|
||||
top: 2px;
|
||||
width: 48px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.uploader-inline .close:before {
|
||||
font: normal 30px/50px dashicons !important;
|
||||
color: #72777c;
|
||||
font: normal 30px/1 dashicons !important;
|
||||
color: #555d66;
|
||||
display: inline-block;
|
||||
content: "\f335";
|
||||
font-weight: 300;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.uploader-inline .close:focus {
|
||||
outline: 1px solid #5b9dd9;
|
||||
-webkit-box-shadow: 0 0 3px rgba( 0, 115, 170, .8 );
|
||||
box-shadow: 0 0 3px rgba( 0, 115, 170, .8 );
|
||||
}
|
||||
|
||||
.attachments-browser.hide-sidebar .attachments,
|
||||
|
@ -623,8 +623,12 @@ Manage = MediaFrame.extend({
|
||||
this.$body = $( document.body );
|
||||
this.$window = $( window );
|
||||
this.$adminBar = $( '#wpadminbar' );
|
||||
// Store the Add New button for later reuse in wp.media.view.UploaderInline.
|
||||
this.$uploaderToggler = $( '.page-title-action' )
|
||||
.attr( 'aria-expanded', 'false' )
|
||||
.on( 'click', _.bind( this.addNewClickHandler, this ) );
|
||||
|
||||
this.$window.on( 'scroll resize', _.debounce( _.bind( this.fixPosition, this ), 15 ) );
|
||||
$( document ).on( 'click', '.page-title-action', _.bind( this.addNewClickHandler, this ) );
|
||||
|
||||
// Ensure core and media grid view UI is enabled.
|
||||
this.$el.addClass('wp-core-ui');
|
||||
|
@ -3771,17 +3771,33 @@ AttachmentsBrowser = View.extend({
|
||||
|
||||
this.controller.on( 'toggle:upload:attachment', this.toggleUploader, this );
|
||||
this.controller.on( 'edit:selection', this.editSelection );
|
||||
this.createToolbar();
|
||||
|
||||
// In the Media Library, the sidebar is used to display errors before the attachments grid.
|
||||
if ( this.options.sidebar && 'errors' === this.options.sidebar ) {
|
||||
this.createSidebar();
|
||||
}
|
||||
|
||||
/*
|
||||
* For accessibility reasons, place the Inline Uploader before other sections.
|
||||
* This way, in the Media Library, it's right after the Add New button, see ticket #37188.
|
||||
*/
|
||||
this.createUploader();
|
||||
|
||||
/*
|
||||
* Create a multi-purpose toolbar. Used as main toolbar in the Media Library
|
||||
* and also for other things, for example the "Drag and drop to reorder" and
|
||||
* "Suggested dimensions" info in the media modal.
|
||||
*/
|
||||
this.createToolbar();
|
||||
|
||||
// Create the list of attachments.
|
||||
this.createAttachments();
|
||||
|
||||
// For accessibility reasons, place the normal sidebar after the attachments, see ticket #36909.
|
||||
if ( this.options.sidebar && 'errors' !== this.options.sidebar ) {
|
||||
this.createSidebar();
|
||||
}
|
||||
|
||||
this.updateContent();
|
||||
|
||||
if ( ! this.options.sidebar || 'errors' === this.options.sidebar ) {
|
||||
@ -4074,7 +4090,7 @@ AttachmentsBrowser = View.extend({
|
||||
canClose: this.controller.isModeActive( 'grid' )
|
||||
});
|
||||
|
||||
this.uploader.hide();
|
||||
this.uploader.$el.addClass( 'hidden' );
|
||||
this.views.add( this.uploader );
|
||||
},
|
||||
|
||||
@ -8210,9 +8226,18 @@ UploaderInline = View.extend({
|
||||
},
|
||||
show: function() {
|
||||
this.$el.removeClass( 'hidden' );
|
||||
if ( this.controller.$uploaderToggler.length ) {
|
||||
this.controller.$uploaderToggler.attr( 'aria-expanded', 'true' );
|
||||
}
|
||||
},
|
||||
hide: function() {
|
||||
this.$el.addClass( 'hidden' );
|
||||
if ( this.controller.$uploaderToggler.length ) {
|
||||
this.controller.$uploaderToggler
|
||||
.attr( 'aria-expanded', 'false' )
|
||||
// Move focus back to the toggle button when closing the uploader.
|
||||
.focus();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -40,17 +40,33 @@ AttachmentsBrowser = View.extend({
|
||||
|
||||
this.controller.on( 'toggle:upload:attachment', this.toggleUploader, this );
|
||||
this.controller.on( 'edit:selection', this.editSelection );
|
||||
this.createToolbar();
|
||||
|
||||
// In the Media Library, the sidebar is used to display errors before the attachments grid.
|
||||
if ( this.options.sidebar && 'errors' === this.options.sidebar ) {
|
||||
this.createSidebar();
|
||||
}
|
||||
|
||||
/*
|
||||
* For accessibility reasons, place the Inline Uploader before other sections.
|
||||
* This way, in the Media Library, it's right after the Add New button, see ticket #37188.
|
||||
*/
|
||||
this.createUploader();
|
||||
|
||||
/*
|
||||
* Create a multi-purpose toolbar. Used as main toolbar in the Media Library
|
||||
* and also for other things, for example the "Drag and drop to reorder" and
|
||||
* "Suggested dimensions" info in the media modal.
|
||||
*/
|
||||
this.createToolbar();
|
||||
|
||||
// Create the list of attachments.
|
||||
this.createAttachments();
|
||||
|
||||
// For accessibility reasons, place the normal sidebar after the attachments, see ticket #36909.
|
||||
if ( this.options.sidebar && 'errors' !== this.options.sidebar ) {
|
||||
this.createSidebar();
|
||||
}
|
||||
|
||||
this.updateContent();
|
||||
|
||||
if ( ! this.options.sidebar || 'errors' === this.options.sidebar ) {
|
||||
@ -343,7 +359,7 @@ AttachmentsBrowser = View.extend({
|
||||
canClose: this.controller.isModeActive( 'grid' )
|
||||
});
|
||||
|
||||
this.uploader.hide();
|
||||
this.uploader.$el.addClass( 'hidden' );
|
||||
this.views.add( this.uploader );
|
||||
},
|
||||
|
||||
|
@ -38,8 +38,12 @@ Manage = MediaFrame.extend({
|
||||
this.$body = $( document.body );
|
||||
this.$window = $( window );
|
||||
this.$adminBar = $( '#wpadminbar' );
|
||||
// Store the Add New button for later reuse in wp.media.view.UploaderInline.
|
||||
this.$uploaderToggler = $( '.page-title-action' )
|
||||
.attr( 'aria-expanded', 'false' )
|
||||
.on( 'click', _.bind( this.addNewClickHandler, this ) );
|
||||
|
||||
this.$window.on( 'scroll resize', _.debounce( _.bind( this.fixPosition, this ), 15 ) );
|
||||
$( document ).on( 'click', '.page-title-action', _.bind( this.addNewClickHandler, this ) );
|
||||
|
||||
// Ensure core and media grid view UI is enabled.
|
||||
this.$el.addClass('wp-core-ui');
|
||||
|
@ -119,9 +119,18 @@ UploaderInline = View.extend({
|
||||
},
|
||||
show: function() {
|
||||
this.$el.removeClass( 'hidden' );
|
||||
if ( this.controller.$uploaderToggler.length ) {
|
||||
this.controller.$uploaderToggler.attr( 'aria-expanded', 'true' );
|
||||
}
|
||||
},
|
||||
hide: function() {
|
||||
this.$el.addClass( 'hidden' );
|
||||
if ( this.controller.$uploaderToggler.length ) {
|
||||
this.controller.$uploaderToggler
|
||||
.attr( 'aria-expanded', 'false' )
|
||||
// Move focus back to the toggle button when closing the uploader.
|
||||
.focus();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user