-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessibility support #465
Comments
The PR yihui/knitr#2243 has now been merged. |
@dmurdoch have you considered having |
@cpsievert : I hadn't considered that before. Now I have, I think it's a bad idea: currently As to the last part of your question: I can imagine a widget that provides an alternate label that is unrelated to So I think the current solution is better (though obviously there might be an even better one). |
That's a fair point. Perhaps a workaround would be to get/set attributes via JS? Maybe by having <script>
(function() {
var el = document.getElementById({{id}}); // id would be populated in R via the widget's HTML
var aria = el.getAttribute('aria-labelledby');
if (!aria) {
el.setAttribute('aria-labelledby', {{id}} + "-knitr-aria");
el.parentElement.querySelector('.caption').setAttribute('id', {{id}} + "-knitr-aria");
}
document.currentScript.remove();
})();
</script> |
The Javascript would need to be more complicated than that - the widget would need some way to communicate to knitr that it wants the label. That's what my htmlwidgets PR was doing with the aria-labelledby attribute. Some widgets shouldn't get aria labels -- see @gtritchie's first comment to the PR #469. |
By default, htmlwidgets are wrapped in
<div>
tags, which don't support "alt" attributes for explanatory text. In yihui/knitr#2243 I have proposed that htmlwidgets which use the "aria-labelledby" attribute should get a text label added, which (at least some) screen readers will treat like alt text.I can do this for the rgl widget by adding a
widget_html.rglWebGL()
function (https://github.com/dmurdoch/rgl/blob/635349d8c2c7deef5fcfa292340c93fb254a3286/R/rglwidget.R#L401-L404) but maybe this should be added by thehtmlwidgets:::widget_html.default()
function (htmlwidgets/R/htmlwidgets.R
Lines 287 to 293 in e234c0e
The text was updated successfully, but these errors were encountered: