Accessibility: Make Safari 10 + VoiceOver announce repeated, identical, `wp.a11y.speak()` messages.

Safari 10 + VoiceOver don't announce repeated, identical, strings sent to an 
`aria-live` region. Appending a `no-break space` to a repeated message string,
forces them to think the strings are different.

Fixes #36853.


git-svn-id: https://develop.svn.wordpress.org/trunk@40479 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrea Fercia 2017-04-19 19:53:00 +00:00
parent 94ad421722
commit 9c5ba6f387
1 changed files with 13 additions and 1 deletions

View File

@ -4,7 +4,8 @@ window.wp = window.wp || {};
'use strict';
var $containerPolite,
$containerAssertive;
$containerAssertive,
previousMessage = '';
/**
* Update the ARIA live notification area text node.
@ -23,6 +24,17 @@ window.wp = window.wp || {};
// Ensure only text is sent to screen readers.
message = $( '<p>' ).html( message ).text();
/*
* Safari 10+VoiceOver don't announce repeated, identical strings. We use
* a `no-break space` to force them to think identical strings are different.
* See ticket #36853.
*/
if ( previousMessage === message ) {
message = message + '\u00A0';
}
previousMessage = message;
if ( $containerAssertive && 'assertive' === ariaLive ) {
$containerAssertive.text( message );
} else if ( $containerPolite ) {