Site Health: Improve `wp.a11y.speak()` notifications.

Improve the experience for screen reader users by removing announcements produced in the Dashboard, simplifying the text to reduce verbosity, and ensuring that messages are spoken in the correct order to match the state of the user interface without repetition.

Props afercia, alexstine.
Fixes #58573.
Built from https://develop.svn.wordpress.org/trunk@56670


git-svn-id: http://core.svn.wordpress.org/trunk@56182 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2023-09-24 20:13:21 +00:00
parent 86c9da14e3
commit 223b713734
3 changed files with 36 additions and 7 deletions

View File

@ -225,12 +225,12 @@ jQuery( function( $ ) {
$wrapper.addClass( 'green' ).removeClass( 'orange' );
$progressLabel.text( __( 'Good' ) );
wp.a11y.speak( __( 'All site health tests have finished running. Your site is looking good, and the results are now available on the page.' ) );
announceTestsProgression( 'good' );
} else {
$wrapper.addClass( 'orange' ).removeClass( 'green' );
$progressLabel.text( __( 'Should be improved' ) );
wp.a11y.speak( __( 'All site health tests have finished running. There are items that should be addressed, and the results are now available on the page.' ) );
announceTestsProgression( 'improvable' );
}
if ( isStatusTab ) {
@ -379,7 +379,7 @@ jQuery( function( $ ) {
// After 3 seconds announce that we're still waiting for directory sizes.
var timeout = window.setTimeout( function() {
wp.a11y.speak( __( 'Please wait...' ) );
announceTestsProgression( 'waiting-for-directory-sizes' );
}, 3000 );
wp.apiRequest( {
@ -390,7 +390,6 @@ jQuery( function( $ ) {
var delay = ( new Date().getTime() ) - timestamp;
$( '.health-check-wp-paths-sizes.spinner' ).css( 'visibility', 'hidden' );
recalculateProgression();
if ( delay > 3000 ) {
/*
@ -405,7 +404,7 @@ jQuery( function( $ ) {
}
window.setTimeout( function() {
wp.a11y.speak( __( 'All site health tests have finished running.' ) );
recalculateProgression();
}, delay );
} else {
// Cancel the announcement.
@ -452,4 +451,34 @@ jQuery( function( $ ) {
$( '.health-check-offscreen-nav-wrapper' ).on( 'click', function() {
$( this ).toggleClass( 'visible' );
} );
/**
* Announces to assistive technologies the tests progression status.
*
* @since 6.4.0
*
* @param {string} type The type of message to be announced.
*
* @return {void}
*/
function announceTestsProgression( type ) {
// Only announce the messages in the Site Health pages.
if ( 'site-health' !== SiteHealth.screen ) {
return;
}
switch ( type ) {
case 'good':
wp.a11y.speak( __( 'All site health tests have finished running. Your site is looking good.' ) );
break;
case 'improvable':
wp.a11y.speak( __( 'All site health tests have finished running. There are items that should be addressed.' ) );
break;
case 'waiting-for-directory-sizes':
wp.a11y.speak( __( 'Running additional tests... please wait.' ) );
break;
default:
return;
}
}
} );

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.4-alpha-56669';
$wp_version = '6.4-alpha-56670';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.