omgovich / react-colorful

🎨 A tiny (2,8 KB) color picker component for React and Preact apps
https://omgovich.github.io/react-colorful
MIT License
3.19k stars 100 forks source link

Slider ARIA properties #171

Closed aitchiss closed 2 years ago

aitchiss commented 2 years ago

Really love this library, especially all the accessibility considerations built in! One thing I've noticed in implementing it though is an error from accessibility validators for a missing aria-valuenow property on both the Color and Hue sliders.

I had an explore of the MDN docs for the two properties aria-valuetext (currently used on these sliders) and aria-valuenow:

The aria-valuetext attribute is used with the aria-valuenow attribute, not instead of it, unless that value is not known.

aria-valuetext is only needed when the numeric value of aria-valuenow is not meaningful

The WAI-ARIA docs for sliders also confirm aria-valuenow is required:

Each slider element has the aria-valuenow property set to a decimal value representing the current value of the slider.

It seems that although aria-valuetext is what actually forms the description announced to screen reader users, the aria-valuenow is still required.

Proposed change

In the case of the Hue component, the valuetext is already number, so I'm hoping it would be simple enough to change aria-valuetext to aria-valuenow, since the additional text description isn't needed.

It's less clear to me whether there's a corresponding numeric value that could be used for the Color slider - what do you think?