mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
fix: make the aria live region assertive (#9436)
This commit is contained in:
@@ -86,7 +86,7 @@ export function inject(
|
||||
const ariaAnnouncementSpan = document.createElement('span');
|
||||
ariaAnnouncementSpan.id = 'blocklyAriaAnnounce';
|
||||
dom.addClass(ariaAnnouncementSpan, 'hiddenForAria');
|
||||
aria.setState(ariaAnnouncementSpan, aria.State.LIVE, 'polite');
|
||||
aria.setState(ariaAnnouncementSpan, aria.State.LIVE, 'assertive');
|
||||
subContainer.appendChild(ariaAnnouncementSpan);
|
||||
|
||||
return workspace;
|
||||
|
||||
@@ -202,20 +202,20 @@ export function getState(element: Element, stateName: State): string | null {
|
||||
}
|
||||
|
||||
/**
|
||||
* Softly requests that the specified text be read to the user if a screen
|
||||
* Assertively requests that the specified text be read to the user if a screen
|
||||
* reader is currently active.
|
||||
*
|
||||
* This relies on a centrally managed ARIA live region that should not interrupt
|
||||
* existing announcements (that is, this is what's considered a polite
|
||||
* announcement).
|
||||
* This relies on a centrally managed ARIA live region that is hidden from the
|
||||
* visual DOM. This live region is assertive, meaning it will interrupt other
|
||||
* text being read.
|
||||
*
|
||||
* Callers should use this judiciously. It's often considered bad practice to
|
||||
* over announce information that can be inferred from other sources on the
|
||||
* page, so this ought to only be used when certain context cannot be easily
|
||||
* over-announce information that can be inferred from other sources on the
|
||||
* page, so this ought to be used only when certain context cannot be easily
|
||||
* determined (such as dynamic states that may not have perfect ARIA
|
||||
* representations or indications).
|
||||
*
|
||||
* @param text The text to politely read to the user.
|
||||
* @param text The text to read to the user.
|
||||
*/
|
||||
export function announceDynamicAriaState(text: string) {
|
||||
const ariaAnnouncementSpan = document.getElementById('blocklyAriaAnnounce');
|
||||
|
||||
Reference in New Issue
Block a user