Devographics / Monorepo

Monorepo containing the State of JS apps
surveyform-sigma.vercel.app
Other
124 stars 50 forks source link

"Compare Date" button in charts is inaccessible to keyboard users #267

Open aardrian opened 12 months ago

aardrian commented 12 months ago

Describe the bug

When navigating the chart view via keyboard I cannot put focus on nor activate the "Compare Data" control.

Browser

Steps to reproduce the bug

  1. Navigate to People on the Resources page.
  2. Choose the "Other Answers" tab.
  3. Navigate through the nested tabs ("Chart", "Data", "Share").
  4. Press arrow keys, Tab↹, or any other key to get to the "Compare Data" control.
  5. Observe it is inaccessible with keyboard alone.

Expected Behavior

Actual Behavior

Related code

The chart is made up of this elided HTML:

<div onclick="[…]">
    <span […] data-state="closed" onclick="[…]">
        <svg […]>
            […]
        </svg>
        <span class="sr-only">
            Compare Data
        </span>
    </span>
</div>

Note there is a click handler on the wrapper <div> and another on the nested <span>.

Also note that the nested <span> has a data-state attribute, which itself has no meaning to browsers.

Also also note that the SVG is not hidden from AT.

Additional Context

The code as shown violates the following WCAG 2.1 Success Criteria:

Consider merging the <div> and <span> into a <button>. This will get you keyboard support for free and you can keep the click handlers.

For the nested SVG, add aria-hidden="true" so it is not exposed to screen readers.

Instead of the data-state attribute, consider adding aria-haspopup="dialog" to the <button>, as support is improving now that NVDA has a fix coming.