Skip to content

Commit cdd8b92

Browse files
committed
Accessibility: Media: Hide the invisible "file input" on media views from assistive technologies.
The file input button is visually hidden, but was announced by screen readers in workflows unrelated to file uploads. It is now hidden from assistive technologies by the means of an `aria-hidden` attribute, as its CSS display property must not be changed to make sure it still works on old browsers. See #49753. Fixes #47611. git-svn-id: https://develop.svn.wordpress.org/trunk@47834 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ea99b19 commit cdd8b92

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/js/_enqueues/vendor/plupload/wp-plupload.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ window.wp = window.wp || {};
120120
* @param {plupload.File} file File that was uploaded.
121121
*/
122122
tryAgain = function( message, data, file ) {
123-
var times;
124-
var id;
123+
var times, id;
125124

126125
if ( ! data || ! data.responseHeaders ) {
127126
error( pluploadL10n.http_error_image, data, file, 'no-retry' );
@@ -210,8 +209,8 @@ window.wp = window.wp || {};
210209
* @param {string} retry Whether to try again to create image sub-sizes. Passing 'no-retry' will prevent it.
211210
*/
212211
error = function( message, data, file, retry ) {
213-
var isImage = file.type && file.type.indexOf( 'image/' ) === 0;
214-
var status = data && data.status;
212+
var isImage = file.type && file.type.indexOf( 'image/' ) === 0,
213+
status = data && data.status;
215214

216215
// If the file is an image and the error is HTTP 5xx try to create sub-sizes again.
217216
if ( retry !== 'no-retry' && isImage && status >= 500 && status < 600 ) {
@@ -327,10 +326,16 @@ window.wp = window.wp || {};
327326
this.browser.on( 'mouseenter', this.refresh );
328327
} else {
329328
this.uploader.disableBrowse( true );
330-
// If HTML5 mode, hide the auto-created file container.
331-
$('#' + this.uploader.id + '_html5_container').hide();
332329
}
333330

331+
$( self ).on( 'uploader:ready', function() {
332+
$( '.moxie-shim-html5 input[type="file"]' )
333+
.attr( {
334+
tabIndex: '-1',
335+
'aria-hidden': 'true'
336+
} );
337+
} );
338+
334339
/**
335340
* After files were filtered and added to the queue, create a model for each.
336341
*
@@ -521,7 +526,7 @@ window.wp = window.wp || {};
521526

522527
/*
523528
* If the browser node is not attached to the DOM,
524-
* use a temporary container to house it, as the browser button shims
529+
* use a temporary container to house it, as the browser button shims
525530
* require the button to exist in the DOM at all times.
526531
*/
527532
if ( ! attached ) {

0 commit comments

Comments
 (0)