<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Marcelo Paiva</title>
    <description>The latest articles on DEV Community by Marcelo Paiva (@mpaiva).</description>
    <link>https://dev.to/mpaiva</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F523365%2F01a3dfe6-9e4a-4e03-a81a-4cefb6c972af.png</url>
      <title>DEV Community: Marcelo Paiva</title>
      <link>https://dev.to/mpaiva</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mpaiva"/>
    <language>en</language>
    <item>
      <title>Using aria-owns with late-mounted descendants</title>
      <dc:creator>Marcelo Paiva</dc:creator>
      <pubDate>Thu, 20 Jul 2023 13:24:10 +0000</pubDate>
      <link>https://dev.to/mpaiva/using-aria-owns-with-late-mounted-descendants-nma</link>
      <guid>https://dev.to/mpaiva/using-aria-owns-with-late-mounted-descendants-nma</guid>
      <description>&lt;p&gt;This post was created to explain how the use of a combination of ARIA attributes can help web developers keeping track of the loading state of a descendant element.&lt;/p&gt;

&lt;p&gt;Review W3C &lt;a href="https://github.com/w3c/aria/issues/1970"&gt;GitHub issue&lt;/a&gt; for more context.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using &lt;code&gt;aria-busy&lt;/code&gt; to track descendant elements status with &lt;code&gt;aria-activedescendant&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;When developing accessible web applications, it is crucial to ensure that the user interface provides accurate and up-to-date information to assistive technologies. &lt;/p&gt;

&lt;p&gt;One common scenario is when a parent element manages the status of its descendant elements dynamically. In such cases, using ARIA attributes like &lt;code&gt;aria-busy&lt;/code&gt; and &lt;code&gt;aria-activedescendant&lt;/code&gt; can be helpful in conveying the loading status and active descendant information to users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scenario: Flight Status List
&lt;/h2&gt;

&lt;p&gt;Let's consider a flight status page as an example. &lt;/p&gt;

&lt;p&gt;We have two lists: "&lt;strong&gt;Expected Flights&lt;/strong&gt;" and "&lt;strong&gt;Arrivals&lt;/strong&gt;". The expected flights list initially displays flight information, and as flights land, the items move to the arrivals list. We want to ensure that the loading and transition states are communicated effectively to assistive technologies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- HTML code snippet --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"expectedFlightsList"&lt;/span&gt; &lt;span class="na"&gt;role=&lt;/span&gt;&lt;span class="s"&gt;"listbox"&lt;/span&gt; &lt;span class="na"&gt;aria-owns=&lt;/span&gt;&lt;span class="s"&gt;"flight1 flight2 flight3 flight4 flight5"&lt;/span&gt; &lt;span class="na"&gt;aria-activedescendant=&lt;/span&gt;&lt;span class="s"&gt;"activeFlight"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we have a parent element with the ID &lt;code&gt;expectedFlightsList&lt;/code&gt;. The &lt;code&gt;aria-owns&lt;/code&gt; attribute specifies the IDs of the expected flight elements. The &lt;code&gt;aria-activedescendant&lt;/code&gt; attribute is initially set to &lt;code&gt;activeFlight&lt;/code&gt;, which will indicate the active or focused descendant within the listbox.&lt;/p&gt;

&lt;p&gt;To handle the loading and transition states, we utilize the &lt;code&gt;aria-busy&lt;/code&gt; attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// JavaScript code snippet&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;flightItem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mountFlight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;flight&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;flightItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aria-busy&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// ... after flight is loaded ...&lt;/span&gt;
&lt;span class="nx"&gt;flightItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aria-busy&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;false&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the JavaScript code, we set the &lt;code&gt;aria-busy&lt;/code&gt; attribute to "true" when a flight is being loaded and then update it to "false" when the flight has been mounted. This informs assistive technologies that the specific flight element is currently undergoing loading or updating.&lt;/p&gt;

&lt;p&gt;As flights transition from the expected flights list to the arrivals list, we update the &lt;code&gt;aria-activedescendant&lt;/code&gt; attribute accordingly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// JavaScript code snippet&lt;/span&gt;
&lt;span class="nx"&gt;flightItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aria-selected&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;expectedFlightsList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aria-activedescendant&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By updating the aria-selected attribute of the active flight item and clearing the &lt;code&gt;aria-activedescendant&lt;/code&gt; attribute on the expected flights list, we ensure that the assistive technologies are aware of the active descendant change.&lt;/p&gt;

&lt;p&gt;These combined uses of &lt;code&gt;aria-busy&lt;/code&gt; and &lt;code&gt;aria-activedescendant&lt;/code&gt; help provide accurate and meaningful information to assistive technologies and users as flights are loaded and transitioned. It enables users relying on screen readers or other assistive technologies to follow the dynamic changes effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;I created a simple demo on codepen to illustrate this issue and test how assistive technologies may announce the state of each descendant element. &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/mpaiva/embed/VwVdzBW?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The usage of ARIA attributes like &lt;code&gt;aria-busy&lt;/code&gt; and &lt;code&gt;aria-activedescendant&lt;/code&gt; allows web developers to enhance accessibility by providing real-time information about loading states and active descendants. &lt;/p&gt;

&lt;p&gt;By leveraging these attributes appropriately, developers can ensure that their web applications are more inclusive and provide a smooth experience for all users.&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>ariaowns</category>
      <category>aria</category>
      <category>activedescendant</category>
    </item>
    <item>
      <title>WCAG 2.1 Checklist with Filter and Links</title>
      <dc:creator>Marcelo Paiva</dc:creator>
      <pubDate>Fri, 16 Jun 2023 17:45:01 +0000</pubDate>
      <link>https://dev.to/mpaiva/wcag-21-checklist-with-filter-and-links-821</link>
      <guid>https://dev.to/mpaiva/wcag-21-checklist-with-filter-and-links-821</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/mpaiva/embed/VwVajBV?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
  </channel>
</rss>
