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.

Built from https://develop.svn.wordpress.org/trunk@40359


git-svn-id: http://core.svn.wordpress.org/trunk@40266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrea Fercia 2017-03-31 17:38:43 +00:00
parent 9c360b1ab8
commit 822b8afb50
14 changed files with 74 additions and 27 deletions

View File

@ -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-right: 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 */
right: auto;
bottom: auto;
padding-top: 0;
margin-top: 0;
margin-top: 20px;
border: 4px dashed #b4b9be;
}

File diff suppressed because one or more lines are too long

View File

@ -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;
}

File diff suppressed because one or more lines are too long

View File

@ -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
}
?>

View File

@ -1133,20 +1133,29 @@
border: 0;
cursor: pointer;
height: 48px;
outline: none;
padding: 0;
position: absolute;
left: 0;
left: 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,

File diff suppressed because one or more lines are too long

View File

@ -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,

File diff suppressed because one or more lines are too long

View File

@ -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');

File diff suppressed because one or more lines are too long

View File

@ -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();
}
}
});

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40358';
$wp_version = '4.8-alpha-40359';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.