Skip to content

Commit 4ab41ba

Browse files
detlevhfischerpatrickhlaukembgower
authored
Aria22 modification for aria-atomic (#1699)
Addressing changes in response to #1137 Adding an explicit `aria-atomic="true"` in Technique [ARIA22: Using role=status to present status messages](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA22) and the linked examples (search results, shopping cart) since the default behaviour of `role="status"` (reading the entire content of a changed container marked with `role="status"`) is currently not well supported. The change to search results example is actually unnecessary since the entire content is written into the container and thus exposed. So not sure whether it is better to skip that change, or change both examples for consistency's sake. Closes #1137 --------- Co-authored-by: Patrick H. Lauke <[email protected]> Co-authored-by: Mike Gower <[email protected]>
1 parent 6ee72a7 commit 4ab41ba

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

techniques/aria/ARIA22.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ <h2>When to Use</h2>
1919
<h2>Description</h2>
2020
<p>
2121
This technique uses the <code>status</code> role from the ARIA specification to notify Assistive Technologies (AT) when content has been updated with information about the user's or application's status. This is done by adding <code>role="status"</code> to the element that contains the <a>status message</a>. The aria live region role of <code>status</code> has an implicit <code>aria-live</code> value of <code>polite</code>, which allows a user to be notified via AT (such as a screen reader) when status messages are added. The role of <code>status</code> also has a default <code>aria-atomic</code> value of <code>true</code>, so that updates to the container marked with a role of <code>status</code> will result in the AT presenting the entire contents of the container to the user, including any author-defined labels (or additional nested elements). Such additional context can be critical where the status message text alone will not provide an equivalent to the visual experience. The content of the aria-live container is automatically read by the AT, without the AT having to focus on the place where the text is displayed. See <a href="https://www.w3.org/TR/wai-aria/#status">WAI-ARIA status (role)</a> for more details.</p>
22-
22+
<p>Note that since <code>role="status"</code> is currently not treated as atomic by default in some environments, it is advisable to add an explicit <code>aria-atomic="true"</code> if the entire contents of the container should be announced.</p>
2323
</section>
2424
<section id="examples">
2525
<h2>Examples</h2>
2626
<section class="example">
2727
<h3>Including a search results message</h3>
2828
<p>After a user presses a Search button, the page content is updated to include the results of the search, which are displayed in a section below the Search button. The change to content also includes the message <samp>"5 results returned"</samp> near the top of this new content. This text is given an appropriate role for a status message. A screen reader will announce "5 results returned".</p>
29-
<pre xml:space="preserve"><code class="language-html">&lt;div role="status"&gt;5 results returned.&lt;/div&gt;</code></pre>
29+
<pre xml:space="preserve"><code class="language-html">&lt;div role="status" aria-atomic="true"&gt;5 results returned.&lt;/div&gt;</code></pre>
3030
<p class="working-example"><a href="../../working-examples/aria-role-status-searchresults/">Working example: role=status on search results</a></p>
3131
</section>
3232
<section class="example">
3333
<h3>Updating the shopping cart status</h3>
34-
<p>After a user presses an Add to Shopping Cart button, content near the Shopping Cart icon updates to read "1 items". The container for this text (in this case a <code class="language-html">&lt;p&gt;</code>) is marked with the role of <code class="language-html">status</code>. Because it adds visual context, the shopping cart image &#8212; with succinct and accurate <code class="language-html">alt</code> text &#8212; is also placed in the container. Due to the default <code class="language-html">aria-atomic</code> value, a screen reader will announce "Shopping cart, six items".</p>
35-
<pre xml:space="preserve"><code class="language-html">&lt;p role="status" &gt;
34+
<p>After a user presses an Add to Shopping Cart button, content near the Shopping Cart icon updates to read "1 items". The container for this text (in this case a <code class="language-html">&lt;p&gt;</code>) is marked with the role of <code class="language-html">status</code>. Because it adds visual context, the shopping cart image &#8212; with succinct and accurate <code class="language-html">alt</code> text &#8212; is also placed in the container. Due to the <code class="language-html">aria-atomic</code> value, a screen reader will announce "Shopping cart, six items".</p>
35+
<pre xml:space="preserve"><code class="language-html">&lt;p role="status" aria-atomic="true"&gt;
3636
&lt;img src="shopping-cart.png" alt="Shopping Cart"&gt;
3737
&lt;span id="cart"&gt;0&lt;/span&gt; items
3838
&lt;/p&gt;

working-examples/aria-role-status-searchresults/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h1>Using <code>role=status</code> to Provide Status Message on Search Results</
1919
</div>
2020
<h2>Results</h2>
2121

22-
<p role="status" id="resultsmsg"></p>
22+
<p role="status" aria-atomic="true" id="resultsmsg"></p>
2323

2424

2525
</div>

working-examples/aria-role-status-shoppingcart/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<h1>Using <code>role=status</code> to Provide Status Message on Shopping Cart</h1>
1818
<p>This simple script demonstrates how a shopping cart counter is updated and surfaced using the aria <code>status</code> role. Here the role is placed on the paragraph containing the dynamically updated text, and the shopping cart image's alt provides additional context. Due to the default <code>aria-atomic="true"</code>, a screenreader should announce "Shopping Cart # items" or (depending on browser compatibility) "# items" each time the Buy Pink Flamingos button is selected.</p>
1919
<hr>
20-
<p role="status"><img src="shopping-cart.png" alt="Shopping Cart"><br>
20+
<p role="status" aria-atomic="true"><img src="shopping-cart.png" alt="Shopping Cart"><br>
2121
<span id="cart">0</span> items</p>
2222

2323
<h2>Shop at our single-product store</h2>

0 commit comments

Comments
 (0)