Open warrickball opened 1 year ago
Thanks @warrickball - do you have a reference for how exactly id
and / or name
attributes improve accessibility? These anchor elements are the actual modebar buttons, rel="tooltip"
looks to me like an obsolete artifact we should remove (the buttons have tooltips added by CSS based on the data-title
attribute).
The buttons are created here:
based on config items in buttons.js
Obvious name
would be config.name
, or id
maybe config.name + '-' + this.graphInfo._fullLayout._uid
I want to first disclaim that I am absolutely not an expert on any of this. My understanding is that this error is associated with principle 4.1.2 of the Web Content Accessibility Guidelines (WCAG) standards (v2.0). Some searching online led me to this advice, which I think suggests using something like the current data-title
for the title
field.
I'll see if I can make that change myself and run pa11y-ci
on it. If that passes, I'm happy to open a PR. I don't know much JavaScript but I'm guessing I could use the same logical block (in the code you linked) that sets data-title
to also set title
.
Hmmm... Just setting the title
attribute didn't work and I wasn't sure about generating a whole set of short names. An alternative recommended here suggests adding a <title>
tag as the first child of the inline SVG element. I copied the short description from data-title
to such an element and pa11y-ci
reports no error. I'll see if I can figure out how to code this.
I think I can see where the new code would go but I think it's beyond me to implement. This looks like the code that creates the icon:
My take would be to try to add an extra child <title>...</title>
at L218, where ...
is the same information that goes into data-title
. But I don't see that being passed down into the icon creator and am not sure how one would do that.
The creator that writes bundled SVG code only seems to apply to newplotlylogo
(see src/fonts/ploticon.js
), so I guess the solution there (and for any hardcoded SVG icons added later) is to add a title
tag to the hardcoded svg
tag.
I'm currently working in a small team on a Django website that has an embedded Plotly Dash. We're working through accessibility issues raised by pa11y-ci and have identified a few that are arising from within Plotly.js itself.
Here's the minimal example I set up based on the "getting started" example code on the Plotly.js website:
I served this using a simple Python server:
and run
pa11y-ci
with this configuration:which produces a number of issues (full log collapsed below), several of which look like this:
There's one of these for each of the tooltips, presumably because they have neither
id
norname
attributes.I'm not sure what the most appopriate
id
orname
attribute would be.Full error log
``` $ npx pa11y-ci Running Pa11y on 1 URLs: 127.0.0.1 - - [15/Jun/2023 15:40:27] "GET /plotly-mwe.html HTTP/1.1" 200 - > http://127.0.0.1:8500/plotly-mwe.html - 22 errors Errors in http://127.0.0.1:8500/plotly-mwe.html: • Page must have means to bypass repeated blocks (https://dequeuniversity.com/rules/axe/4.7/bypass?application=axeAPI) (html)