<?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: Hitesh Gharate</title>
    <description>The latest articles on DEV Community by Hitesh Gharate (@hitesh_dev_io).</description>
    <link>https://dev.to/hitesh_dev_io</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4222685%2Fda021258-a7d6-4754-9676-6fafa0850596.png</url>
      <title>DEV Community: Hitesh Gharate</title>
      <link>https://dev.to/hitesh_dev_io</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hitesh_dev_io"/>
    <language>en</language>
    <item>
      <title>Semantic HTML and Page Structure in Angular: Fixing Openbook's Foundation</title>
      <dc:creator>Hitesh Gharate</dc:creator>
      <pubDate>Thu, 03 Dec 2026 20:01:38 +0000</pubDate>
      <link>https://dev.to/hitesh_dev_io/semantic-html-and-page-structure-in-angular-fixing-openbooks-foundation-7ei</link>
      <guid>https://dev.to/hitesh_dev_io/semantic-html-and-page-structure-in-angular-fixing-openbooks-foundation-7ei</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 2 of a series on Angular accessibility. &lt;a href="https://dev.toLINK_TO_POST_1"&gt;Part 1&lt;/a&gt; introduced Openbook, a fictional demo app that starts out deliberately inaccessible.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In Part 1, I read through Openbook's code and listed what I expected to go wrong. This post starts fixing it, beginning with the foundation: the HTML itself. Most of the changes are small, and they make the biggest difference to keyboard and screen reader users, because everything else builds on them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repo:&lt;/strong&gt; &lt;a href="https://github.com/Hitesh-Gharate/openbook-angular-a11y" rel="noopener noreferrer"&gt;openbook-angular-a11y&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Before:&lt;/strong&gt; &lt;a href="https://github.com/Hitesh-Gharate/openbook-angular-a11y/tree/post-01-baseline" rel="noopener noreferrer"&gt;&lt;code&gt;post-01-baseline&lt;/code&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;After:&lt;/strong&gt; &lt;a href="https://github.com/Hitesh-Gharate/openbook-angular-a11y/tree/post-02-after" rel="noopener noreferrer"&gt;&lt;code&gt;post-02-after&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As in Part 1, I haven't run an automated scanner or a screen reader against this version. The changes below follow from how native HTML elements and ARIA attributes are defined to behave. I'll point out where behavior is worth checking yourself.&lt;/p&gt;
&lt;h2&gt;
  
  
  What we're fixing
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;th&gt;Problem in the baseline&lt;/th&gt;
&lt;th&gt;Fix in this post&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A01&lt;/td&gt;
&lt;td&gt;No landmarks&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A02&lt;/td&gt;
&lt;td&gt;No skip link&lt;/td&gt;
&lt;td&gt;"Skip to main content" link&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A03&lt;/td&gt;
&lt;td&gt;Navigation built from clickable &lt;code&gt;div&lt;/code&gt;s&lt;/td&gt;
&lt;td&gt;Real links with &lt;code&gt;routerLink&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A04&lt;/td&gt;
&lt;td&gt;Icon buttons with no accessible name&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;aria-label&lt;/code&gt;, hidden decorative SVGs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A05&lt;/td&gt;
&lt;td&gt;Skipped and misused heading levels&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;h1&lt;/code&gt; then &lt;code&gt;h2&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A19&lt;/td&gt;
&lt;td&gt;No &lt;code&gt;lang&lt;/code&gt; on the page&lt;/td&gt;
&lt;td&gt;&lt;code&gt;lang="en"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  1. Landmarks: give the page a map
&lt;/h2&gt;

&lt;p&gt;Before, the whole shell was &lt;code&gt;div&lt;/code&gt;s:&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="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"topbar"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"logo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Openbook&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  ...
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"content"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;router-outlet&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After:&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="nt"&gt;&amp;lt;header&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"topbar"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"logo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Openbook&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;nav&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"nav"&lt;/span&gt; &lt;span class="na"&gt;aria-label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Main"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    ...
  &lt;span class="nt"&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;
  ...
&lt;span class="nt"&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;main&lt;/span&gt; &lt;span class="na"&gt;#main&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"main"&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"content"&lt;/span&gt; &lt;span class="na"&gt;tabindex&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"-1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;router-outlet&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; are landmarks. Screen readers can list them and jump straight to the one the user wants, instead of reading through the page from the top. The &lt;code&gt;aria-label="Main"&lt;/code&gt; on the nav matters once a page has more than one navigation region, because it tells them apart.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;tabindex="-1"&lt;/code&gt; on &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; doesn't put it in the Tab order. It only allows us to move focus there from code, which we need for the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A skip link, and an Angular gotcha
&lt;/h2&gt;

&lt;p&gt;Keyboard users have to Tab through every navigation item on every page before reaching the content. A skip link lets them jump past it:&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="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"skip-link"&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#main"&lt;/span&gt; &lt;span class="na"&gt;(click)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"skipToMain($event, main)"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Skip to main content
&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;skipToMain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HTMLElement&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;focus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nc"&gt;.skip-link&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;-9999px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;z-index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8px&lt;/span&gt; &lt;span class="mi"&gt;12px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.skip-link&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;focus&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The link is off-screen until it receives focus, then it appears in the top-left corner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why not just a plain &lt;code&gt;href="#main"&lt;/code&gt;?&lt;/strong&gt; Openbook's &lt;code&gt;index.html&lt;/code&gt; has &lt;code&gt;&amp;lt;base href="/"&amp;gt;&lt;/code&gt;, which Angular apps use for routing. With that tag present, a bare &lt;code&gt;#main&lt;/code&gt; link resolves against the base URL, so the browser can treat it as a navigation to &lt;code&gt;/#main&lt;/code&gt; instead of a jump within the page. In an app like this one, that can trigger a route change. Handling the click ourselves and focusing &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; avoids the problem. I'd suggest trying the link in your own app, since behavior depends on your routing setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Real links instead of clickable divs
&lt;/h2&gt;

&lt;p&gt;This was the most serious baseline flaw. Before:&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="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"nav-item"&lt;/span&gt; &lt;span class="na"&gt;(click)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"go('/accounts')"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Accounts&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;div&lt;/code&gt; isn't focusable and doesn't respond to Enter, so it's out of reach for keyboard users. It also tells a screen reader nothing about being navigation. After:&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="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"nav-item"&lt;/span&gt; &lt;span class="na"&gt;routerLink&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/accounts"&lt;/span&gt;
   &lt;span class="na"&gt;routerLinkActive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"active"&lt;/span&gt; &lt;span class="na"&gt;ariaCurrentWhenActive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"page"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Accounts&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A native &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; with an &lt;code&gt;href&lt;/code&gt; (which &lt;code&gt;routerLink&lt;/code&gt; provides) is focusable, activates with Enter, can be opened in a new tab, and is announced as a link. &lt;code&gt;routerLinkActive&lt;/code&gt; adds a CSS class to the current page's link, and &lt;code&gt;ariaCurrentWhenActive="page"&lt;/code&gt; sets &lt;code&gt;aria-current="page"&lt;/code&gt; so assistive technology knows which link is current.&lt;/p&gt;

&lt;p&gt;I styled the active link as bold and underlined, not just a different color, so the state doesn't depend on color alone.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Check:&lt;/em&gt; I believe &lt;code&gt;ariaCurrentWhenActive&lt;/code&gt; is available on &lt;code&gt;routerLinkActive&lt;/code&gt; in recent Angular versions, but confirm it against the Angular documentation for the version you use.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Name the icon buttons
&lt;/h2&gt;

&lt;p&gt;Before:&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="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"icon-btn"&lt;/span&gt; &lt;span class="na"&gt;(click)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"go('/accounts')"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;viewBox&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0 0 24 24"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"..."&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A button with only an SVG inside has no text, so there's nothing for a screen reader to announce except "button". After:&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="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"button"&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"icon-btn"&lt;/span&gt; &lt;span class="na"&gt;aria-label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Notifications"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;aria-hidden&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt; &lt;span class="na"&gt;focusable&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"false"&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;viewBox&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0 0 24 24"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"..."&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two small changes: &lt;code&gt;aria-label&lt;/code&gt; gives the button its accessible name, and &lt;code&gt;aria-hidden="true"&lt;/code&gt; on the SVG hides the decorative drawing so it isn't announced as an extra, unnamed graphic. I also added &lt;code&gt;type="button"&lt;/code&gt; as a good habit. It stops a button from accidentally submitting a form if it's ever placed inside one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One honest caveat:&lt;/strong&gt; in the baseline, these buttons navigated to Accounts and Login, which would have made accurate labels misleading. So I removed that behavior. They're now named placeholders until later posts add real notifications and a settings dialog. A named button that does nothing is still a flaw, and I'm flagging it in the repo's &lt;code&gt;known-issues.md&lt;/code&gt; rather than hiding it.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Headings: one &lt;code&gt;h1&lt;/code&gt;, then a logical outline
&lt;/h2&gt;

&lt;p&gt;Headings are how many screen reader users scan a page. In the baseline, Login used an &lt;code&gt;h3&lt;/code&gt; as its only heading, and Accounts jumped from &lt;code&gt;h1&lt;/code&gt; to &lt;code&gt;h4&lt;/code&gt;. The fix is mostly renaming:&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;!-- login.html --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Welcome back&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- accounts.html --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Accounts&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
...
&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;{{ a.name }}&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
...
&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Recent transactions&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A useful rule: choose heading levels for &lt;strong&gt;structure&lt;/strong&gt;, not for how they look. If the default size is wrong, change it with CSS, not by picking a different level. That's why the stylesheet now sets sizes for &lt;code&gt;h2&lt;/code&gt; and the card's &lt;code&gt;h1&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Declare the page language
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One attribute, and it tells screen readers which language rules to use for pronunciation. I'd left it out of the baseline by mistake, so I'm counting it as a planted flaw and fixing it here.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's still broken (on purpose)
&lt;/h2&gt;

&lt;p&gt;This post only fixes structure. These are still in the app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inputs with no labels and &lt;code&gt;div&lt;/code&gt; submit buttons (Part 3)&lt;/li&gt;
&lt;li&gt;No visible focus indicator, and the page title never changes (Part 4)&lt;/li&gt;
&lt;li&gt;The silent toast message (Part 5)&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;div&lt;/code&gt;-based transactions "table" (Part 7)&lt;/li&gt;
&lt;li&gt;Low color contrast (Part 8)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The repo's &lt;code&gt;docs/known-issues.md&lt;/code&gt; tracks every item and which post fixes it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it yourself
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repo and check out &lt;code&gt;post-02-after&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;npm install&lt;/code&gt; and &lt;code&gt;ng serve&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Put your mouse aside and press Tab. Does the skip link appear first? Can you reach all three navigation links?&lt;/li&gt;
&lt;li&gt;Press Enter on the skip link. Where does focus go?&lt;/li&gt;
&lt;li&gt;If you use a screen reader, open its landmarks and headings lists on each page.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Even before fixing focus styles, these checks show how much a handful of correct elements changes the experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next
&lt;/h2&gt;

&lt;p&gt;In Part 3, we fix the forms: real labels, accessible error messages, and buttons that submit.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Which of these fixes do you most often find missing in the Angular apps you work on? Tell me in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>a11y</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Why Openbook Fails: A Code-Review Accessibility Audit of an Angular App</title>
      <dc:creator>Hitesh Gharate</dc:creator>
      <pubDate>Tue, 01 Dec 2026 17:54:24 +0000</pubDate>
      <link>https://dev.to/hitesh_dev_io/why-openbook-fails-a-code-review-accessibility-audit-of-an-angular-app-4274</link>
      <guid>https://dev.to/hitesh_dev_io/why-openbook-fails-a-code-review-accessibility-audit-of-an-angular-app-4274</guid>
      <description>&lt;p&gt;&lt;em&gt;Part 1 of a series on Angular accessibility, from a deliberately broken baseline to a fixed app.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I've spent years building large Angular applications, and accessibility problems almost always come from small, ordinary decisions made under deadline pressure. To show that, I built &lt;strong&gt;Openbook&lt;/strong&gt;, a small fictional personal-finance app, and made it inaccessible on purpose. Over this series, I'll fix it step by step.&lt;/p&gt;

&lt;p&gt;Openbook is a demo. The data is invented, there's no backend or real authentication, and it has no connection to any real product or company.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repo:&lt;/strong&gt; &lt;a href="https://github.com/Hitesh-Gharate/openbook-angular-a11y" rel="noopener noreferrer"&gt;openbook-angular-a11y&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Starting point:&lt;/strong&gt; the &lt;a href="https://github.com/Hitesh-Gharate/openbook-angular-a11y/tree/post-01-baseline" rel="noopener noreferrer"&gt;&lt;code&gt;post-01-baseline&lt;/code&gt;&lt;/a&gt; tag&lt;/p&gt;

&lt;h2&gt;
  
  
  How this audit was done (and what it isn't)
&lt;/h2&gt;

&lt;p&gt;This post is a &lt;strong&gt;code-review audit&lt;/strong&gt;. I read the source and find what a user with a keyboard or a screen reader would hit. I have &lt;strong&gt;not yet&lt;/strong&gt; run axe, tested with NVDA or VoiceOver, or checked zoom behavior. Everything below is a prediction, not a measurement.&lt;/p&gt;

&lt;p&gt;Part 2 will compare these predictions against real tool results, including where I turn out to be wrong. Automated tools find only part of the problems, so I'm splitting the findings into what a scanner will probably catch and what it probably won't.&lt;/p&gt;

&lt;h2&gt;
  
  
  The app
&lt;/h2&gt;

&lt;p&gt;Openbook has three screens: a login form, an accounts dashboard with a transactions list, and a money-transfer form. Navigation and a toast message sit on top of them. It's built with Angular 21, standalone components and signals.&lt;/p&gt;

&lt;h2&gt;
  
  
  What an automated scanner will probably flag
&lt;/h2&gt;

&lt;p&gt;These issues are structural, so I expect tools like axe to report them. I'll confirm the exact rule names in Part 2.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Icon buttons with no accessible name
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"icon-btn"&lt;/span&gt; &lt;span class="na"&gt;(click)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"go('/accounts')"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;svg&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;viewBox&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"0 0 24 24"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;path&lt;/span&gt; &lt;span class="na"&gt;d&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"..."&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&amp;lt;/svg&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A screen reader user hears "button" and nothing else. There's no text, no &lt;code&gt;aria-label&lt;/code&gt;, and no title.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. No landmarks, no main region
&lt;/h3&gt;

&lt;p&gt;The whole shell is made of &lt;code&gt;div&lt;/code&gt;s. There's no &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;, so screen reader users can't jump between regions, and there's no skip link.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Heading problems
&lt;/h3&gt;

&lt;p&gt;The login page uses an &lt;code&gt;h3&lt;/code&gt; as its only heading. The accounts page goes from &lt;code&gt;h1&lt;/code&gt; straight to &lt;code&gt;h4&lt;/code&gt;. Headings are how many screen reader users scan a page, so skipped levels make the structure hard to follow.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. A select with no name
&lt;/h3&gt;

&lt;p&gt;The "from account" dropdown on the transfer page has no label.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Low color contrast
&lt;/h3&gt;

&lt;p&gt;The navigation links, the icons and the helper text use light colors on backgrounds that, by my reading of the CSS values, are likely to fail the WCAG AA contrast ratio. I haven't measured the ratios yet.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Possibly no page language
&lt;/h3&gt;

&lt;p&gt;The page may not declare its language, which affects how screen readers pronounce the text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A note on placeholder-only inputs:&lt;/strong&gt; both the login and transfer forms rely on placeholders instead of labels. I'm not sure whether axe treats a placeholder as an accessible name. If it doesn't flag them, that's worth discussing: a scanner passing isn't the same as the form being usable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a scanner will probably miss
&lt;/h2&gt;

&lt;p&gt;These are the ones that hurt users most, and they need manual testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Clickable divs instead of buttons and links
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"nav-item"&lt;/span&gt; &lt;span class="na"&gt;(click)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"go('/accounts')"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Accounts&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"btn"&lt;/span&gt; &lt;span class="na"&gt;(click)&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"signIn(email.value, pass.value)"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Sign in&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;div&lt;/code&gt; can't be reached with the Tab key and doesn't respond to Enter or Space. A keyboard user can't navigate the app or even sign in. Forms built this way also lose the Enter-to-submit behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Focus outlines removed
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even where focus lands, sighted keyboard users can't see where they are.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Meaning carried by color alone
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Login errors are a red "!" and nothing else.&lt;/li&gt;
&lt;li&gt;Invalid transfer fields only get a red border, with no error text and no &lt;code&gt;aria-invalid&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Credits and debits differ only by green or red text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Color alone excludes people with color blindness and anyone using a screen reader.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The transactions "table" isn't a table
&lt;/h3&gt;

&lt;p&gt;It's built from &lt;code&gt;div&lt;/code&gt;s, so screen readers can't announce rows, columns or headers. The sortable "Amount" header is a &lt;code&gt;div&lt;/code&gt; with a click handler, so it's unreachable by keyboard and doesn't announce its sort state.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. The toast is silent
&lt;/h3&gt;

&lt;p&gt;The "Transfer sent" message appears visually and disappears after four seconds. Without a live region, a screen reader user may never know it happened.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Navigation gives no signal
&lt;/h3&gt;

&lt;p&gt;The page title never changes between screens, and focus doesn't move when the route changes. In a single-page app, a screen reader user may not realize the page changed at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prediction summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Area&lt;/th&gt;
&lt;th&gt;Flaw&lt;/th&gt;
&lt;th&gt;Scanner likely to catch?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Structure&lt;/td&gt;
&lt;td&gt;No landmarks or skip link&lt;/td&gt;
&lt;td&gt;Partly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Structure&lt;/td&gt;
&lt;td&gt;Heading levels skipped&lt;/td&gt;
&lt;td&gt;Likely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Controls&lt;/td&gt;
&lt;td&gt;Icon buttons unnamed&lt;/td&gt;
&lt;td&gt;Likely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Controls&lt;/td&gt;
&lt;td&gt;Clickable &lt;code&gt;div&lt;/code&gt;s&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Forms&lt;/td&gt;
&lt;td&gt;Placeholder-only inputs&lt;/td&gt;
&lt;td&gt;Unsure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Forms&lt;/td&gt;
&lt;td&gt;Color-only errors&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Forms&lt;/td&gt;
&lt;td&gt;Select without a name&lt;/td&gt;
&lt;td&gt;Likely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keyboard&lt;/td&gt;
&lt;td&gt;Focus outline removed&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data&lt;/td&gt;
&lt;td&gt;Div-based table&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic&lt;/td&gt;
&lt;td&gt;Silent toast&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Navigation&lt;/td&gt;
&lt;td&gt;Static title, no focus move&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Visual&lt;/td&gt;
&lt;td&gt;Low contrast&lt;/td&gt;
&lt;td&gt;Likely&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Roughly half of these are things scanners tend to miss. That's the main lesson of this post: a clean automated report is a starting point, not proof of accessibility.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessibility findings, tool by tool
&lt;/h2&gt;

&lt;p&gt;Here is the full audit checklist I plan to run in Part 2, with my prediction for each tool. Every line below is a &lt;strong&gt;prediction from reading the code&lt;/strong&gt;. The "Measured" column stays empty until I've actually run the check.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. axe DevTools (automated scan)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Page&lt;/th&gt;
&lt;th&gt;issues&lt;/th&gt;
&lt;th&gt;Measured&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;All pages&lt;/td&gt;
&lt;td&gt;Unnamed icon buttons, low contrast on nav links and icons, missing landmarks or main region, possibly missing page language&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Login&lt;/td&gt;
&lt;td&gt;No level-one heading (only an &lt;code&gt;h3&lt;/code&gt;), low-contrast "Forgot password?" text&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accounts&lt;/td&gt;
&lt;td&gt;Heading order skips from &lt;code&gt;h1&lt;/code&gt; to &lt;code&gt;h4&lt;/code&gt;, low-contrast helper text&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transfer&lt;/td&gt;
&lt;td&gt;Select with no accessible name&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I'm not predicting violation counts. I can't know them from reading code, and a guessed number would be misleading.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Keyboard-only walkthrough
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Page&lt;/th&gt;
&lt;th&gt;behavior&lt;/th&gt;
&lt;th&gt;Measured&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;All pages&lt;/td&gt;
&lt;td&gt;The nav items are &lt;code&gt;div&lt;/code&gt;s, so Tab should skip them. Only the two icon buttons should be reachable. No visible focus indicator on anything.&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Login&lt;/td&gt;
&lt;td&gt;Both text fields should be reachable. "Sign in" is a &lt;code&gt;div&lt;/code&gt;, so it shouldn't be reachable, and pressing Enter in a field shouldn't submit. Keyboard users likely can't sign in.&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Accounts&lt;/td&gt;
&lt;td&gt;Nothing in the content area should be focusable, and the sortable "Amount" header should be unreachable.&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transfer&lt;/td&gt;
&lt;td&gt;The select and both inputs should be reachable. "Send" is a &lt;code&gt;div&lt;/code&gt;, so it likely can't be activated by keyboard.&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One oddity I expect: the bell icon button navigates to Accounts, and the gear button to Login. So a keyboard user may be able to reach Accounts through an unnamed icon, but not Transfer.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Screen reader (NVDA on Windows, VoiceOver on macOS)
&lt;/h3&gt;

&lt;p&gt;Screen readers differ from each other and from browser to browser, so these are my weakest predictions.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Area&lt;/th&gt;
&lt;th&gt;behavior&lt;/th&gt;
&lt;th&gt;Measured&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Icon buttons&lt;/td&gt;
&lt;td&gt;Announced as just "button", with no name&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Navigation&lt;/td&gt;
&lt;td&gt;Read as plain text, not as links or buttons&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Login and transfer inputs&lt;/td&gt;
&lt;td&gt;Announced as edit fields. Whether the placeholder is used as the name may vary by screen reader&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Headings list&lt;/td&gt;
&lt;td&gt;Login shows one &lt;code&gt;h3&lt;/code&gt;. Accounts shows &lt;code&gt;h1&lt;/code&gt; followed by &lt;code&gt;h4&lt;/code&gt;s&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transactions&lt;/td&gt;
&lt;td&gt;Read as a flat run of text, with no table, row or column information&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transfer toast&lt;/td&gt;
&lt;td&gt;Likely not announced at all&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Route changes&lt;/td&gt;
&lt;td&gt;No announcement that the page changed&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  4. Page title
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;result&lt;/th&gt;
&lt;th&gt;Measured&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Browser tab title across login, accounts and transfer&lt;/td&gt;
&lt;td&gt;"Openbook" on every page, because no route sets a title&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  5. Zoom to 200%
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;result&lt;/th&gt;
&lt;th&gt;Measured&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Layout at 200% browser zoom&lt;/td&gt;
&lt;td&gt;Probably mostly usable, since cards wrap. Possible trouble spots: the top bar, the fixed three-column transactions grid, and the fixed-position toast overlapping content. I'm unsure.&lt;/td&gt;
&lt;td&gt;To be added&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;In Part 2, I'll run axe on all three pages and compare the results to this list, including where I got it wrong. Then I'll start fixing, beginning with semantic HTML, landmarks and headings.&lt;/p&gt;

&lt;p&gt;Clone the repo, check out &lt;code&gt;post-01-baseline&lt;/code&gt;, and try the app with your keyboard only. How far do you get?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What accessibility problem do you run into most often in Angular projects? I'd like to hear it in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>a11y</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Testing accessibility in AG Grid: a grid-aware helper for Jest and Playwright</title>
      <dc:creator>Hitesh Gharate</dc:creator>
      <pubDate>Tue, 03 Nov 2026 20:52:05 +0000</pubDate>
      <link>https://dev.to/hitesh_dev_io/testing-accessibility-in-ag-grid-a-grid-aware-helper-for-jest-and-playwright-3ap0</link>
      <guid>https://dev.to/hitesh_dev_io/testing-accessibility-in-ag-grid-a-grid-aware-helper-for-jest-and-playwright-3ap0</guid>
      <description>&lt;p&gt;Dense data grids are where accessibility problems like to hide. A table with thousands of rows, virtualized columns, inline buttons and color-coded values can look fine and still be hard to use with a keyboard or a screen reader.&lt;/p&gt;

&lt;p&gt;General tools such as axe-core are great for checking a page. They are not built around grid-specific questions: Is the total row count exposed when rows are virtualized? Does the arrow key actually move focus one cell? Is a status shown only by a colored dot?&lt;/p&gt;

&lt;p&gt;So I wrote a small helper, &lt;strong&gt;ag-grid-a11y-test&lt;/strong&gt;, that adds grid-aware checks on top of the tools you already use. This post shows how to use it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Status: early preview (alpha), not on npm yet.&lt;/strong&gt; The code is public on GitHub and I am sharing it so people can try it and give feedback. The rules come from the ARIA grid pattern and AG Grid's commonly rendered markup. I have not yet validated them against every AG Grid version, so treat findings as prompts to investigate, not proof of conformance. Your feedback will decide what changes next.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What it checks
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Structure (works in jsdom or a real browser):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The grid has a &lt;code&gt;grid&lt;/code&gt; or &lt;code&gt;treegrid&lt;/code&gt; role and an accessible name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aria-rowcount&lt;/code&gt; and &lt;code&gt;aria-colcount&lt;/code&gt; are present and consistent with row and column indexes (important for virtualized grids)&lt;/li&gt;
&lt;li&gt;Rows and cells have &lt;code&gt;aria-rowindex&lt;/code&gt; and &lt;code&gt;aria-colindex&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Column headers have accessible names (this catches icon-only headers)&lt;/li&gt;
&lt;li&gt;Sortable headers expose &lt;code&gt;aria-sort&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Patterns common in financial and data-heavy tables:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Icon-only buttons and checkboxes with no accessible name&lt;/li&gt;
&lt;li&gt;Cells that show only an icon or colored element, with no text&lt;/li&gt;
&lt;li&gt;Negative values shown by color alone (opt-in, you tell it your CSS class)&lt;/li&gt;
&lt;li&gt;Abbreviated numbers like &lt;code&gt;1.2M&lt;/code&gt; (advisory)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Keyboard navigation (real browser, via Playwright):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrow keys move focus one cell and return to the start&lt;/li&gt;
&lt;li&gt;Tab can eventually leave the grid (a warning if not, since a very large grid can cause false positives)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each finding has a severity: &lt;code&gt;error&lt;/code&gt; (very likely a real problem), &lt;code&gt;warning&lt;/code&gt; (verify), or &lt;code&gt;info&lt;/code&gt; (advisory).&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;p&gt;The package is not published to npm yet, so install it from the GitHub repo. Clone it and build a local package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Hitesh-Gharate/accessibility.git
&lt;span class="nb"&gt;cd &lt;/span&gt;accessibility
npm &lt;span class="nb"&gt;install
&lt;/span&gt;npm run build
npm pack   &lt;span class="c"&gt;# creates ag-grid-a11y-test-0.1.0.tgz&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then install that file into your Angular project (adjust the path):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; ../accessibility/ag-grid-a11y-test-0.1.0.tgz
&lt;span class="c"&gt;# optional, for the axe-core adapter&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; axe-core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The examples below import from &lt;code&gt;ag-grid-a11y-test&lt;/code&gt;, which is the package name inside that file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use it in an Angular unit test (Jest)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;TestBed&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core/testing&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;auditGrid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;assertNoViolations&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;formatReport&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ag-grid-a11y-test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;PositionsGridComponent&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./positions-grid.component&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;positions grid passes accessibility checks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fixture&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;TestBed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PositionsGridComponent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;detectChanges&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;whenStable&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;detectChanges&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;auditGrid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;nativeElement&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;gridSelector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.ag-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;negativeValueClasses&lt;/span&gt;&lt;span class="p"&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;loss&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// your app's class for negative values (optional)&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;formatReport&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// everything, including warnings and info&lt;/span&gt;
  &lt;span class="nf"&gt;assertNoViolations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;        &lt;span class="c1"&gt;// fails the test on errors only&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;jsdom has no layout engine, so AG Grid may not render rows unless virtualization is turned off in your test grid options. Check the AG Grid docs for the exact option names in your version.&lt;/p&gt;

&lt;p&gt;A failing result reads like this (an example of the report format):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Grid accessibility audit: 1 error(s), 0 warning(s), 0 info.
  [ERROR] grid-rowcount: The grid is missing a valid integer aria-rowcount (use -1 if the total is unknown).
      at div.ag-root
      help: Without it, virtualized grids do not tell assistive technology how many rows exist.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To be stricter, use &lt;code&gt;assertNoViolations(result, { failOn: ['error', 'warning'] })&lt;/code&gt;. To silence a rule you have reviewed, use &lt;code&gt;ignoreRules: ['abbreviated-number']&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use it in a real browser (Playwright)
&lt;/h2&gt;

&lt;p&gt;A real browser is the most reliable option, and it is the only way to test keyboard behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;test&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@playwright/test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;AxeBuilder&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@axe-core/playwright&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;auditKeyboardNavigation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fromAxeResults&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mergeResults&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;assertNoViolations&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ag-grid-a11y-test&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;positions grid is accessible&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;goto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/positions&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitForSelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.ag-root [role=gridcell]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// 1. Structure and pattern checks, executed inside the page&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addScriptTag&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ag-grid-a11y-test/browser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;domResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;evaluate&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lib&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;AgGridA11y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;lib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;serialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;lib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;auditGrid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;gridSelector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.ag-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="c1"&gt;// 2. axe-core, scoped to the grid&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;axe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fromAxeResults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AxeBuilder&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.ag-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;analyze&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

  &lt;span class="c1"&gt;// 3. Keyboard navigation&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;keyboard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;auditKeyboardNavigation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;gridSelector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.ag-root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nf"&gt;assertNoViolations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;mergeResults&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;domResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;axe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;keyboard&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All three sources are merged into one report, so axe findings and grid-specific findings appear together.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it cannot do
&lt;/h2&gt;

&lt;p&gt;Please read this part before relying on it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automated checks find only a subset of accessibility problems. You still need manual keyboard testing and screen reader testing (NVDA, JAWS, VoiceOver).&lt;/li&gt;
&lt;li&gt;Several rules are heuristics and can produce false positives: &lt;code&gt;visual-only-cell&lt;/code&gt;, &lt;code&gt;abbreviated-number&lt;/code&gt; and &lt;code&gt;kbd-tab-trap&lt;/code&gt; in particular.&lt;/li&gt;
&lt;li&gt;Passing this audit does not mean WCAG conformance.&lt;/li&gt;
&lt;li&gt;The test fixtures in the repo are hand-written approximations of AG Grid markup, not captured output from a specific release.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is next
&lt;/h2&gt;

&lt;p&gt;Planned work includes integration tests against real AG Grid output for each major version, Home/End and Page Up/Down navigation, cell-editing keyboard flow, a visible-focus check, and row selection and group expand/collapse state.&lt;/p&gt;

&lt;p&gt;If you try it on your own grid and a rule misfires or misses something, please open an issue with your AG Grid version, the rule id, and the smallest HTML snippet that reproduces it (remove any confidential data first). Pull requests are welcome too.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/Hitesh-Gharate/accessibility" rel="noopener noreferrer"&gt;Hitesh-Gharate/accessibility&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Issues and ideas: &lt;a href="https://github.com/Hitesh-Gharate/accessibility/issues" rel="noopener noreferrer"&gt;open an issue&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Not affiliated with or endorsed by AG Grid. AG Grid is a trademark of its owner.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>frontend</category>
      <category>javascript</category>
      <category>testing</category>
    </item>
    <item>
      <title>Fixing Angular race conditions with switchMap and shareReplay</title>
      <dc:creator>Hitesh Gharate</dc:creator>
      <pubDate>Mon, 02 Nov 2026 16:02:12 +0000</pubDate>
      <link>https://dev.to/hitesh_dev_io/fixing-angular-race-conditions-with-switchmap-and-sharereplay-2c0g</link>
      <guid>https://dev.to/hitesh_dev_io/fixing-angular-race-conditions-with-switchmap-and-sharereplay-2c0g</guid>
      <description>&lt;p&gt;Your search box works fine in dev. In production, users type fast, the network is uneven, and suddenly the results on screen don't match what they typed.&lt;/p&gt;

&lt;p&gt;That's a race condition, and RxJS gives us clean tools to fix it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Here's a typical typeahead search:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchControl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;valueChanges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Type "ang", then "angular". Both requests fly out. If the "ang" response arrives last, it overwrites the right results. Nested subscribes also leak and are hard to clean up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 1: switchMap cancels stale requests
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchControl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;valueChanges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nf"&gt;switchMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When a new value arrives, &lt;code&gt;switchMap&lt;/code&gt; unsubscribes from the previous inner request and cancels it. Only the latest request can ever emit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 2: reduce noise with debounceTime and distinctUntilChanged
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchControl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;valueChanges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nf"&gt;debounceTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nf"&gt;distinctUntilChanged&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
  &lt;span class="nf"&gt;switchMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;debounceTime(300)&lt;/code&gt; waits until the user pauses typing.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;distinctUntilChanged()&lt;/code&gt; skips repeats of the same value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means fewer API calls and less load on your backend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 3: handle errors without killing the stream
&lt;/h2&gt;

&lt;p&gt;If the HTTP call errors, the whole stream dies and search stops working. Catch the error inside the inner observable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;switchMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nf"&gt;catchError&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="p"&gt;([]))&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Second race: duplicate requests with multiple subscribers
&lt;/h2&gt;

&lt;p&gt;Say a component template reads the same observable twice:&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="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;*ngIf=&lt;/span&gt;&lt;span class="s"&gt;"(user$ | async) as user"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{{ user.name }}&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;{{ (user$ | async)?.email }}&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each &lt;code&gt;async&lt;/code&gt; pipe subscribes separately, so you get &lt;strong&gt;two HTTP calls&lt;/strong&gt;, which can return different data at different times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 4: shareReplay shares one request
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;user$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;http&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="o"&gt;&amp;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;/api/user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nf"&gt;shareReplay&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;bufferSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;refCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now all subscribers share one request, and late subscribers get the last cached value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why &lt;code&gt;refCount: true&lt;/code&gt;?&lt;/strong&gt; Without it, the source subscription stays alive even after all subscribers leave, which can cause leaks. With it, the source is released when nobody is listening.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting it together
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SearchComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;searchControl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormControl&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;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;nonNullable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="nx"&gt;results$&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;searchControl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;valueChanges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nf"&gt;debounceTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;distinctUntilChanged&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="nf"&gt;switchMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;term&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;catchError&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="p"&gt;([])))&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;shareReplay&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;bufferSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;refCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SearchService&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;[formControl]=&lt;/span&gt;&lt;span class="s"&gt;"searchControl"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;*ngFor=&lt;/span&gt;&lt;span class="s"&gt;"let r of results$ | async"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;{{ r.name }}&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No manual subscriptions, no cleanup code, and no stale results.&lt;/p&gt;

&lt;h2&gt;
  
  
  When NOT to use switchMap
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;switchMap&lt;/code&gt; cancels in-flight work, which is perfect for reads but risky for writes. Pick the operator by intent:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Use for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;switchMap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Searches, autocomplete, latest-wins reads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;concatMap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Writes that must run in order&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;exhaustMap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ignore repeat clicks, such as a submit button&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;mergeMap&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Independent parallel work&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Using &lt;code&gt;switchMap&lt;/code&gt; on a save request could cancel a write mid-flight, so use &lt;code&gt;concatMap&lt;/code&gt; or &lt;code&gt;exhaustMap&lt;/code&gt; there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Nested subscribes cause race conditions and leaks.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;switchMap&lt;/code&gt; gives you "latest wins" for reads.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;debounceTime&lt;/code&gt; and &lt;code&gt;distinctUntilChanged&lt;/code&gt; cut unnecessary calls.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;shareReplay({ bufferSize: 1, refCount: true })&lt;/code&gt; prevents duplicate requests.&lt;/li&gt;
&lt;li&gt;Choose the flattening operator based on what the request does.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've used these patterns on large Angular applications, and they remove a whole class of "works on my machine" bugs. What race condition have you run into? Let me know in the comments.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>rxjs</category>
      <category>typescript</category>
      <category>a11y</category>
    </item>
  </channel>
</rss>
