Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessibility: Page Loader indicator using aria-live

Issue: I have an accessibility issue that I am struggling with. I have an angular web application. A page loading spinner/indicator is shown when content is loading. And when the page content has loaded the spinner is hidden. This "div" is never removed from DOM.

Content of the loading div are not read (by NVDAor jaws) when the loading div is shown.

<div class='loading' aria-live='polite' aria-label='Do not refresh the page' tabindex="-1">Do not refresh the page</div>

I wouldn't like to change the structure of the application but work around using 'aria tags' to resolve this, just wondering if I will have to do anything more to make aria-live work?

Updated (27/July/2016)

Further clarification: I am not removing the content from DOM but using css to show/hide content (display: none to display: block and vice versa)

like image 974
akhouri Avatar asked Jul 22 '16 04:07

akhouri


People also ask

What is aria Live used for?

The aria-live attribute makes it possible for an AT (such as a screen reader) to be notified when error messages are injected into a Live Region container. The content within the aria-live region is automatically read by the AT, without the AT having to focus on the place where the text is displayed.

What is aria in accessibility testing?

Overview. ARIA is a W3C specification that stands for “Accessible Rich Internet Applications.” It consists of markup that can be added to HTML in order to communicate the roles, states, and properties of user interface elements to assistive technologies (AT).

Is aria-label read by screen reader?

The aria-label attribute provides the text label for an object, such as a button. When a screen reader encounters the object, the aria-label text is read so that the user will know what it is.

What is aria live assertive?

aria-live="assertive" should only be used for time-sensitive/critical notifications that absolutely require the user's immediate attention. Generally, a change to an assertive live region will interrupt any announcement a screen reader is currently making.


1 Answers

aria-live triggers screen readers when an element with aria-live (or text within an element with aria-live) is added or removed from the DOM. In contrast, when you unhide a hidden element, neither elements nor text are added or removed from the DOM, so the element's aria-live property doesn’t come into play.

To get screen readers to announce “Do not refresh the page”, either of these options should do the trick:

  • You can create the <div class='loading' aria-live='polite'> element and its text content from scratch and then add that element to the DOM.
  • Or you can start with an empty <div class='loading' aria-live='polite'> element and then populate its text content.

A few other tidbits:

  • As long as the text inside the element is what you want to be read aloud, you can omit the element’s aria-label='Do not refresh the page' attribute.
  • For icing on the cake, it can’t hurt to include a role attribute on the div that has aria-live. If you’re not sure which role to use, go with role="status"—that’s a pretty safe bet.
  • When or if the page is at a state where you no longer need to display "Do not refresh the page”, be sure to reverse the steps above. (That is, if you went with the first option and you added the whole element to the DOM, remove that entire element from the DOM. Or if you went with the second option and you populated the element’s text content, clear out the element’s text content.)
like image 125
Ashley Bischoff Avatar answered Nov 15 '22 10:11

Ashley Bischoff