<?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: Richard JP Le Guen</title>
    <description>The latest articles on DEV Community by Richard JP Le Guen (@richardjpleguen).</description>
    <link>https://dev.to/richardjpleguen</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%2F285791%2F8b3a7379-dc6d-4397-b1bc-c2434dc4c9d7.jpg</url>
      <title>DEV Community: Richard JP Le Guen</title>
      <link>https://dev.to/richardjpleguen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/richardjpleguen"/>
    <language>en</language>
    <item>
      <title>How do you support incrementing a `role="spinbutton"` with Voiceover?</title>
      <dc:creator>Richard JP Le Guen</dc:creator>
      <pubDate>Thu, 05 Dec 2019 13:07:55 +0000</pubDate>
      <link>https://dev.to/richardjpleguen/incrementing-a-role-spinbutton-with-voiceover-3b1o</link>
      <guid>https://dev.to/richardjpleguen/incrementing-a-role-spinbutton-with-voiceover-3b1o</guid>
      <description>&lt;p&gt;I'm struggling to implement an accessible input with increment/decrement behaviors, using an &lt;code&gt;&amp;lt;input type="text" role="spinbutton" /&amp;gt;&lt;/code&gt; element in HTML/JavaScript. But it seems like with VoiceOver there are custom (fake?) input events for incrementing/decrementing which change the input's value in unexpected ways.&lt;/p&gt;

&lt;p&gt;How do I make sure a user navigating the page with assistive technology doesn't get bad guidance from VoiceOver while trying to interact with my widget?&lt;/p&gt;

&lt;p&gt;For example, using super trimmed-down code like this:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function logIt(...args) {
  document.getElementById('output').appendChild(
    document.createTextNode(`${args.join(', ')}\n`)
  );
}

document.getElementById("myInput").addEventListener('input', (e) =&amp;gt; {
  debugger;
  logIt(e.type, e.data, String(e));
  e.target.setAttribute('aria-valuenow', e.target.value);
}, false);

document.getElementById("myInput").addEventListener('keydown', (e) =&amp;gt; {
  logIt(e.type, e.data, String(e));
}, false);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      &amp;lt;input
        id="myInput"
        type="text"
        role="spinbutton"
        autocomplete="off"
        defaultValue="1"
        aria-valuenow="1"
        aria-valuemin="0"
        aria-valuemax="100"
      /&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;pre id="output"&amp;gt;&amp;lt;/pre&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;... VoiceOver will describe the input as a "stepper" and give instructions on how to increment/decrement using the keyboard. But using those keyboard commands results in some weird math, as seen in this screen cap:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.stack.imgur.com/RQuPE.gif"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PUcpDG_M--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.stack.imgur.com/RQuPE.gif" alt="animated screen capture of attempts to increment with VoiceOver keyboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also see (from the "logging" in the screen cap) that when the user types input, an &lt;code&gt;InputEvent&lt;/code&gt; is triggered with &lt;code&gt;event.type&lt;/code&gt; being &lt;code&gt;input&lt;/code&gt; - but when the VoiceOver keyboard command for increment/decrement is used, a base-type &lt;code&gt;Event&lt;/code&gt; is triggered with &lt;code&gt;event.type&lt;/code&gt; again set to &lt;code&gt;input&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And this doesn't seem to be unique to my implementations of &lt;code&gt;role="spinbutton"&lt;/code&gt;. The jQuery UI spinner doesn't behave well when incremented/decremented using VoiceOver keyboard commands:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.stack.imgur.com/pr4yM.gif"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j_k6nXca--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.stack.imgur.com/pr4yM.gif" alt="animated screen capture of jQuery UI spinner being incremented using VoiceOver and the value changing to some unexpected scientific notation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I even tried some of the w3c's examples for &lt;code&gt;role="spinbutton"&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The font size widget on &lt;a href="https://www.w3.org/TR/wai-aria-practices/examples/toolbar/toolbar.html"&gt;https://www.w3.org/TR/wai-aria-practices/examples/toolbar/toolbar.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The date picker on &lt;a href="https://www.w3.org/TR/wai-aria-practices/examples/spinbutton/datepicker-spinbuttons.html"&gt;https://www.w3.org/TR/wai-aria-practices/examples/spinbutton/datepicker-spinbuttons.html&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;... and even though VoiceOver described each of those UI controls as a "stepper" and gave instructions on how to increment/decrement them using the keyboard, those instructions didn't seem to work. Other keyboard behaviors worked - but the ones VoiceOver suggests don't.&lt;/p&gt;

&lt;p&gt;What can I do to make sure that &lt;code&gt;role="spinbutton"&lt;/code&gt; markup works correctly with VoiceOver's increment/decrement keyboard commands?&lt;/p&gt;

</description>
      <category>help</category>
      <category>a11y</category>
      <category>html</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
