Revisions: Improve accessibility of revisions selection.

Add `aria-labelledby` and `aria-describedby` attributes to revision slider selection handle. Add keyboard `:focus` state to revision slider  handle. Move 'multiple revision' checkbox before the buttons panel, matching its visual order. Change diff `Title` and `Content` headings from `h3` to `h2` to correct headings hierarchy.

Props joedolson, rishishah, sarahricker, williamalexander, afercia. 
Fixes #52303.
Built from https://develop.svn.wordpress.org/trunk@59225


git-svn-id: http://core.svn.wordpress.org/trunk@58617 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2024-10-13 20:49:13 +00:00
parent f7fb13a3c4
commit 0c88366123
8 changed files with 63 additions and 16 deletions

View File

@ -459,8 +459,7 @@ div.revisions-controls > .wp-slider > .ui-slider-handle {
touch-action: none; touch-action: none;
} }
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle {
.wp-slider .ui-slider-handle.focus {
background: #f6f7f7; background: #f6f7f7;
border: 1px solid #c3c4c7; border: 1px solid #c3c4c7;
box-shadow: 0 1px 0 #c3c4c7; box-shadow: 0 1px 0 #c3c4c7;
@ -480,6 +479,15 @@ div.revisions-controls > .wp-slider > .ui-slider-handle {
transform: translateY(1px); transform: translateY(1px);
} }
.wp-slider .ui-slider-handle:focus,
.wp-slider .ui-slider-handle.ui-state-focus {
background: #f0f0f1;
border-color: #8c8f94;
box-shadow: 0 0 0 2px #2271b1;
/* Only visible in Windows High Contrast mode */
outline: 2px solid transparent;
}
.wp-slider .ui-slider-handle:before { .wp-slider .ui-slider-handle:before {
background: none; background: none;
position: absolute; position: absolute;

File diff suppressed because one or more lines are too long

View File

@ -458,8 +458,7 @@ div.revisions-controls > .wp-slider > .ui-slider-handle {
touch-action: none; touch-action: none;
} }
.wp-slider .ui-slider-handle, .wp-slider .ui-slider-handle {
.wp-slider .ui-slider-handle.focus {
background: #f6f7f7; background: #f6f7f7;
border: 1px solid #c3c4c7; border: 1px solid #c3c4c7;
box-shadow: 0 1px 0 #c3c4c7; box-shadow: 0 1px 0 #c3c4c7;
@ -479,6 +478,15 @@ div.revisions-controls > .wp-slider > .ui-slider-handle {
transform: translateY(1px); transform: translateY(1px);
} }
.wp-slider .ui-slider-handle:focus,
.wp-slider .ui-slider-handle.ui-state-focus {
background: #f0f0f1;
border-color: #8c8f94;
box-shadow: 0 0 0 2px #2271b1;
/* Only visible in Windows High Contrast mode */
outline: 2px solid transparent;
}
.wp-slider .ui-slider-handle:before { .wp-slider .ui-slider-handle:before {
background: none; background: none;
position: absolute; position: absolute;

File diff suppressed because one or more lines are too long

View File

@ -378,6 +378,11 @@ function wp_print_revision_templates() {
</div> </div>
</script> </script>
<script id="tmpl-revisions-slider-hidden-help" type="text/html">
<h2 class="screen-reader-text"><?php esc_html_e( 'Select a revision' ); ?></h2>
<p id="revisions-slider-hidden-help" hidden><?php esc_html_e( 'Change revision by using the left and arrow keys' ); ?></p>
</script>
<script id="tmpl-revisions-checkbox" type="text/html"> <script id="tmpl-revisions-checkbox" type="text/html">
<div class="revision-toggle-compare-mode"> <div class="revision-toggle-compare-mode">
<label> <label>
@ -397,13 +402,13 @@ function wp_print_revision_templates() {
<# if ( ! _.isUndefined( data.attributes ) ) { #> <# if ( ! _.isUndefined( data.attributes ) ) { #>
<div class="diff-title"> <div class="diff-title">
<# if ( 'from' === data.type ) { #> <# if ( 'from' === data.type ) { #>
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong> <strong id="diff-title-from"><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
<# } else if ( 'to' === data.type ) { #> <# } else if ( 'to' === data.type ) { #>
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong> <strong id="diff-title-to"><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
<# } #> <# } #>
<div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>"> <div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
{{{ data.attributes.author.avatar }}} {{{ data.attributes.author.avatar }}}
<div class="author-info"> <div class="author-info" id="diff-title-author">
<# if ( data.attributes.autosave ) { #> <# if ( data.attributes.autosave ) { #>
<span class="byline"> <span class="byline">
<?php <?php
@ -464,7 +469,7 @@ function wp_print_revision_templates() {
<div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div> <div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div>
<div class="diff"> <div class="diff">
<# _.each( data.fields, function( field ) { #> <# _.each( data.fields, function( field ) { #>
<h3>{{ field.name }}</h3> <h2>{{ field.name }}</h2>
{{{ field.diff }}} {{{ field.diff }}}
<# }); #> <# }); #>
</div> </div>

View File

@ -595,13 +595,13 @@ window.wp = window.wp || {};
initialize: function() { initialize: function() {
_.bindAll( this, 'setWidth' ); _.bindAll( this, 'setWidth' );
// Add the button view. // Add the checkbox view.
this.views.add( new revisions.view.Buttons({ this.views.add( new revisions.view.Checkbox({
model: this.model model: this.model
}) ); }) );
// Add the checkbox view. // Add the button view.
this.views.add( new revisions.view.Checkbox({ this.views.add( new revisions.view.Buttons({
model: this.model model: this.model
}) ); }) );
@ -628,6 +628,9 @@ window.wp = window.wp || {};
model: tooltip model: tooltip
}) ); }) );
// Add the visually hidden slider help view.
this.views.add( new revisions.view.SliderHelp() );
// Add the slider view. // Add the slider view.
this.views.add( new revisions.view.Slider({ this.views.add( new revisions.view.Slider({
model: slider model: slider
@ -804,6 +807,12 @@ window.wp = window.wp || {};
} }
}); });
// The slider visually hidden help view.
revisions.view.SliderHelp = wp.Backbone.View.extend({
className: 'revisions-slider-hidden-help',
template: wp.template( 'revisions-slider-hidden-help' )
});
// The tooltip view. // The tooltip view.
// Encapsulates the tooltip. // Encapsulates the tooltip.
revisions.view.Tooltip = wp.Backbone.View.extend({ revisions.view.Tooltip = wp.Backbone.View.extend({
@ -957,6 +966,20 @@ window.wp = window.wp || {};
this.applySliderSettings(); this.applySliderSettings();
}, },
accessibilityHelper: function() {
var handles = $( '.ui-slider-handle' );
handles.first().attr( {
role: 'button',
'aria-labelledby': 'diff-title-from diff-title-author',
'aria-describedby': 'revisions-slider-hidden-help',
} );
handles.last().attr( {
role: 'button',
'aria-labelledby': 'diff-title-to diff-title-author',
'aria-describedby': 'revisions-slider-hidden-help',
} );
},
mouseMove: function( e ) { mouseMove: function( e ) {
var zoneCount = this.model.revisions.length - 1, // One fewer zone than models. var zoneCount = this.model.revisions.length - 1, // One fewer zone than models.
sliderFrom = this.$el.allOffsets()[this.direction], // "From" edge of slider. sliderFrom = this.$el.allOffsets()[this.direction], // "From" edge of slider.
@ -996,9 +1019,12 @@ window.wp = window.wp || {};
handles.last() handles.last()
.toggleClass( 'from-handle', !! isRtl ) .toggleClass( 'from-handle', !! isRtl )
.toggleClass( 'to-handle', ! isRtl ); .toggleClass( 'to-handle', ! isRtl );
this.accessibilityHelper();
} else { } else {
handles.removeClass('from-handle to-handle'); handles.removeClass('from-handle to-handle');
this.accessibilityHelper();
} }
}, },
start: function( event, ui ) { start: function( event, ui ) {

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.7-beta2-59224'; $wp_version = '6.7-beta2-59225';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.