Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read aloud at start and stop of progress bar (md-progress-linear)

I need to use NVDA screen-reader to read some messages when a dialog with progress bar appears.

At 0% duration of progress-bar, I need to announce: "Your received a timed message"

At 100% duration of progress-bar: "The message expired"

The progress-bar used is md-progress-linear.

The html code looks like below:

<md-dialog>
    <md-progress-linear tabindex="0" ng-if="displayProgressIndicator || timeoutValue > 0" md-mode="determinate" class="promptProgressBar" value="{{progressValue}}"></md-progress-linear>
    <md-content class="md-title dialogTitle">
        {{messageTitle}}
    </md-content>
    <md-content class="md-dialog-content">
        {{messageText}}
    </md-content>
    <div class="md-dialog-actions">
        <md-button ng-style="theme.SecondaryButton" ng-click="OnClose()" class="md-primary right">
            {{primaryActionText}}
        </md-button>
        <md-button ng-style="theme.SecondaryButton" ng-if="secondaryActionText.length > 0" ng-click="OnCancel()" class="md-primary right">
            {{secondaryActionText}}
        </md-button>
    </div>
</md-dialog>

I saw some working examples for slider which uses aria-valuetext attribute and NVDA reads those texts properly.

I tried adding aria-valuetext attribute in md-progress-linear element, but doesn't work.

When the message is arrived, NVDA produces beep sounds, but do not read aria-valuetext.

Any idea on how to do it?

like image 444
Coding man Avatar asked Jun 13 '18 10:06

Coding man


People also ask

What are the different types of progress bars?

There are 2 types of progress bars: determinate and indeterminate. The former is used when the amount of information that needs to be loaded is detectable. The latter is used when the system is unsure how much needs to be loaded or how long it will take.

How do I create a progress bar in HTML?

Use the <progress> tag to create a progress bar in HTML. The HTML <progress> tag specifies a completion progress of a task. It is displayed as a progress bar. The value of progress bar can be manipulated by JavaScript.


1 Answers

TL;DR

You can use aria-live region to achieve the same

Here is a working codepen : Output: https://codepen.io/aimt/details/PaaKXM/

Code : https://codepen.io/aimt/pen/PaaKXM/


Refrences

More details available in mdn https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions

and https://www.w3.org/TR/wai-aria-1.1/#aria-live

Details

Add <div aria-live="polite" id="livePolite"></div> to your page

Aria-live is an empty container with aria-live="assertive" or aria-live="polite"

  • aria-live="polite" will wait for the screen reader to finish its statement before announcing new content.
  • aria-live="assertive" will cut the screen reader off to announce new content.

Important

The container MUST be present on page load (or you must enforce a JavaScript delay after the aria-live region is added to the DOM before injecting the message into it; 500 milliseconds is usually sufficient, but you should test it). You cannot load an aria-live container with a message already inside it.

The container MUST also be empty, to begin with. This is because screen readers will be looking for a change in content in the aria-live container.

Behaviour

Screen readers will announce content when content has been injected into the container.

o Before: <div aria-live="polite" id="livePolite"></div>

o After: <div aria-live="polite" id="livePolite">Paused Video</div>

I always keep these on top of my webpage and populate whenever required

<p aria-live="polite" id="livePolite"></p> <p aria-live="assertive" id="liveAssertive"></p>

like image 66
Sengupta Amit Avatar answered Nov 08 '22 22:11

Sengupta Amit