-
Notifications
You must be signed in to change notification settings - Fork 208
Add "aria-labelledby" attribute #469
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
base: master
Are you sure you want to change the base?
Changes from all commits
71cdf52
0f75439
f5b93f5
cda6f67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -167,6 +167,12 @@ addHook <- function(x, hookName, jsCode, data = NULL) { | |||||||||
| x | ||||||||||
| } | ||||||||||
|
|
||||||||||
| do_use_aria <- function(knitrOptions) { | ||||||||||
| getOption("htmlwidgets.USE_ARIA") %||% | ||||||||||
| ("fig.alt" %in% names(knitrOptions) && | ||||||||||
| isNamespaceLoaded("knitr") && | ||||||||||
| packageVersion("knitr") >= "1.42.12") | ||||||||||
| } | ||||||||||
|
|
||||||||||
| toHTML <- function(x, standalone = FALSE, knitrOptions = NULL) { | ||||||||||
|
|
||||||||||
|
|
@@ -192,7 +198,8 @@ toHTML <- function(x, standalone = FALSE, knitrOptions = NULL) { | |||||||||
| if (sizeInfo$fill) "html-fill-item-overflow-hidden" | ||||||||||
| ), | ||||||||||
| width = sizeInfo$width, | ||||||||||
| height = sizeInfo$height | ||||||||||
| height = sizeInfo$height, | ||||||||||
| use_aria = do_use_aria(knitrOptions) | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| html <- bindFillRole(html, item = sizeInfo$fill) | ||||||||||
|
|
@@ -257,18 +264,22 @@ lookup_widget_html_method <- function(name, package) { | |||||||||
| list(fn = widget_html.default, name = "widget_html.default", legacy = FALSE) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| widget_html <- function(name, package, id, style, class, inline = FALSE, ...) { | ||||||||||
| widget_html <- function(name, package, id, style, class, inline = FALSE, use_aria = FALSE, ...) { | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. It might make sense to use some test like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the knitr options aren't strictly necessary because the global R option is checked before the knitr options. So it'd be reasonable to do either
Suggested change
or to default to args$use_aria <- use_aria %||% do_use_aria()In either case, I'd prefer to add
Suggested change
|
||||||||||
|
|
||||||||||
| fn_info <- lookup_widget_html_method(name, package) | ||||||||||
|
|
||||||||||
| fn <- fn_info[["fn"]] | ||||||||||
| # id, style, and class have been required args for years, but inline is fairly new | ||||||||||
| # and undocumented, so unsuprisingly there are widgets out there are don't have an | ||||||||||
| # and undocumented, so unsurprisingly there are widgets out there that don't have an | ||||||||||
| # inline arg https://github.com/renkun-ken/formattable/blob/484777/R/render.R#L79-L88 | ||||||||||
| args <- list(id = id, style = style, class = class, ...) | ||||||||||
| if ("inline" %in% names(formals(fn))) { | ||||||||||
| args$inline <- inline | ||||||||||
| } | ||||||||||
| # use_aria was added to support accessibility in knitr | ||||||||||
| if ("use_aria" %in% names(formals(fn))) { | ||||||||||
| args$use_aria <- use_aria | ||||||||||
| } | ||||||||||
| fn_res <- do.call(fn, args) | ||||||||||
| if (isTRUE(fn_info[["legacy"]])) { | ||||||||||
| # For the PACKAGE:::NAME_html form (only), we worry about false positives; | ||||||||||
|
|
@@ -284,11 +295,14 @@ widget_html <- function(name, package, id, style, class, inline = FALSE, ...) { | |||||||||
| fn_res | ||||||||||
| } | ||||||||||
|
|
||||||||||
| widget_html.default <- function (name, package, id, style, class, inline = FALSE, ...) { | ||||||||||
| widget_html.default <- function (name, package, id, style, class, inline = FALSE, use_aria = FALSE, ...) { | ||||||||||
| if (inline) { | ||||||||||
| tags$span(id = id, style = style, class = class) | ||||||||||
| } else { | ||||||||||
| } else if (!use_aria) { | ||||||||||
| tags$div(id = id, style = style, class = class) | ||||||||||
| } else { | ||||||||||
| tags$div(id = id, style = style, class = class, | ||||||||||
| "aria-labelledby" = paste0(id, "-aria")) | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.