Accessibility: Change the posts "Quick Edit" link to a button.

For better accessibility and semantics, user interface controls that perform an
action should be buttons. Links should exclusively be used for navigation. Also,
adds an `aria-expanded` attribute to the button to communicate to assistive
technologies the expanded / collapsed status of the Quick Edit form.

Props Cheffheid, audrasjb, afercia.
Fixes #38677.

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


git-svn-id: http://core.svn.wordpress.org/trunk@42555 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrea Fercia 2018-02-21 22:31:32 +00:00
parent ebeb2bcf5b
commit 4767e7736c
4 changed files with 15 additions and 11 deletions

View File

@ -1267,7 +1267,7 @@ if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->p
__( 'Edit' )
);
$actions['inline hide-if-no-js'] = sprintf(
'<a href="#" class="editinline" aria-label="%s">%s</a>',
'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
/* translators: %s: post title */
esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $title ) ),
__( 'Quick&nbsp;Edit' )

View File

@ -119,11 +119,11 @@ var inlineEditPost;
});
/**
* Binds click event to the .editinline link which opens the quick editor.
* Binds click event to the .editinline button which opens the quick editor.
*/
$('#the-list').on( 'click', 'a.editinline', function( e ) {
e.preventDefault();
inlineEditPost.edit(this);
$( '#the-list' ).on( 'click', '.editinline', function() {
$( this ).attr( 'aria-expanded', 'true' );
inlineEditPost.edit( this );
});
$('#bulk-edit').find('fieldset:first').after(
@ -422,8 +422,10 @@ var inlineEditPost;
$(inlineEditPost.what+id).siblings('tr.hidden').addBack().remove();
$('#edit-'+id).before(r).remove();
$( inlineEditPost.what + id ).hide().fadeIn( 400, function() {
// Move focus back to the Quick Edit link. $( this ) is the row being animated.
$( this ).find( '.editinline' ).focus();
// Move focus back to the Quick Edit button. $( this ) is the row being animated.
$( this ).find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
wp.a11y.speak( inlineEditL10n.saved );
});
} else {
@ -477,8 +479,10 @@ var inlineEditPost;
$('#'+id).siblings('tr.hidden').addBack().remove();
id = id.substr( id.lastIndexOf('-') + 1 );
// Show the post row and move focus back to the Quick Edit link.
$( this.what + id ).show().find( '.editinline' ).focus();
// Show the post row and move focus back to the Quick Edit button.
$( this.what + id ).show().find( '.editinline' )
.attr( 'aria-expanded', 'false' )
.focus();
}
}

File diff suppressed because one or more lines are too long

View File

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