From 9c5ba6f387748212e041e7d76981b239ef619a89 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Wed, 19 Apr 2017 19:53:00 +0000 Subject: [PATCH] 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 --- src/wp-includes/js/wp-a11y.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/js/wp-a11y.js b/src/wp-includes/js/wp-a11y.js index 2507cbc2f4..7ccdd75403 100644 --- a/src/wp-includes/js/wp-a11y.js +++ b/src/wp-includes/js/wp-a11y.js @@ -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 = $( '

' ).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 ) {