Accessibility: Media: Add an `aria-pressed` attribute to active button within a button group.

The `aria-pressed` attribute communicates semantically the "active" state of buttons that otherwise only look "active".

Fixes #48355.


git-svn-id: https://develop.svn.wordpress.org/trunk@46748 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrea Fercia 2019-11-18 22:21:26 +00:00
parent 4ebaf2b2d2
commit 82e352e412
1 changed files with 6 additions and 2 deletions

View File

@ -69,8 +69,12 @@ Settings = View.extend(/** @lends wp.media.view.Settings.prototype */{
// Handle button groups. // Handle button groups.
} else if ( $setting.hasClass('button-group') ) { } else if ( $setting.hasClass('button-group') ) {
$buttons = $setting.find('button').removeClass('active'); $buttons = $setting.find( 'button' )
$buttons.filter( '[value="' + value + '"]' ).addClass('active'); .removeClass( 'active' )
.attr( 'aria-pressed', 'false' );
$buttons.filter( '[value="' + value + '"]' )
.addClass( 'active' )
.attr( 'aria-pressed', 'true' );
// Handle text inputs and textareas. // Handle text inputs and textareas.
} else if ( $setting.is('input[type="text"], textarea') ) { } else if ( $setting.is('input[type="text"], textarea') ) {