Skip to content

Commit

Permalink
Rename header args to heading in utils_accessibility + use tagQuery t…
Browse files Browse the repository at this point in the history
…o fix bug in nhs_card_tabstop
  • Loading branch information
MarkMc1089 committed Nov 3, 2023
1 parent 9a25dbb commit 0fd3bff
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 48 deletions.
1 change: 1 addition & 0 deletions R/mod_chart_example.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod_chart_example_ui <- function(id) {
h2_tabstop("Second level"),
nhs_card_tabstop(
heading = "example chart title",
tabindex = 0,
nhs_selectInput(
inputId = ns("bins"),
label = "Number of bins:",
Expand Down
71 changes: 37 additions & 34 deletions R/utils_accessibility.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' h1_tabstop
#'
#' @param header Heading text
#' @param heading Heading text
#' @param tabindex Number for tabindex, default 0
#' @inheritDotParams shiny::h1
#'
Expand All @@ -9,16 +9,16 @@
#'
#' @examples
#' h1_tabstop("Heading")
h1_tabstop <- function(header, tabindex = 0, ...) {
# create header as typical header plus tabindex attribute
# ensures header will be stopped at when pressing keyboard tab
h1_tabstop <- h1(header, ...) %>%
h1_tabstop <- function(heading, tabindex = 0, ...) {
# create heading as typical heading plus tabindex attribute
# ensures heading will be stopped at when pressing keyboard tab
h1_tabstop <- h1(heading, ...) %>%
htmltools::tagAppendAttributes(`tabindex` = tabindex)
}

#' h2_tabstop
#'
#' @param header Heading text
#' @param heading Heading text
#' @param tabindex Number for tabindex, default 0
#' @inheritDotParams shiny::h2
#'
Expand All @@ -27,16 +27,16 @@ h1_tabstop <- function(header, tabindex = 0, ...) {
#'
#' @examples
#' h2_tabstop("Heading")
h2_tabstop <- function(header, tabindex = 0, ...) {
# create header as typical header plus tabindex attribute
# ensures header will be stopped at when pressing keyboard tab
h2_tabstop <- h2(header, ...) %>%
h2_tabstop <- function(heading, tabindex = 0, ...) {
# create heading as typical heading plus tabindex attribute
# ensures heading will be stopped at when pressing keyboard tab
h2_tabstop <- h2(heading, ...) %>%
htmltools::tagAppendAttributes(`tabindex` = tabindex)
}

#' h3_tabstop
#'
#' @param header Heading text
#' @param heading Heading text
#' @param tabindex Number for tabindex, default 0
#' @inheritDotParams shiny::h3
#'
Expand All @@ -45,16 +45,16 @@ h2_tabstop <- function(header, tabindex = 0, ...) {
#'
#' @examples
#' h3_tabstop("Heading")
h3_tabstop <- function(header, tabindex = 0, ...) {
# create header as typical header plus tabindex attribute
# ensures header will be stopped at when pressing keyboard tab
h3_tabstop <- h3(header, ...) %>%
h3_tabstop <- function(heading, tabindex = 0, ...) {
# create heading as typical heading plus tabindex attribute
# ensures heading will be stopped at when pressing keyboard tab
h3_tabstop <- h3(heading, ...) %>%
htmltools::tagAppendAttributes(`tabindex` = tabindex)
}

#' h4_tabstop
#'
#' @param header Heading text
#' @param heading Heading text
#' @param tabindex Number for tabindex, default 0
#' @inheritDotParams shiny::h4
#'
Expand All @@ -63,16 +63,16 @@ h3_tabstop <- function(header, tabindex = 0, ...) {
#'
#' @examples
#' h4_tabstop("Heading")
h4_tabstop <- function(header, tabindex = 0, ...) {
# create header as typical header plus tabindex attribute
# ensures header will be stopped at when pressing keyboard tab
h4_tabstop <- h4(header, ...) %>%
h4_tabstop <- function(heading, tabindex = 0, ...) {
# create heading as typical heading plus tabindex attribute
# ensures heading will be stopped at when pressing keyboard tab
h4_tabstop <- h4(heading, ...) %>%
htmltools::tagAppendAttributes(`tabindex` = tabindex)
}

#' h5_tabstop
#'
#' @param header Heading text
#' @param heading Heading text
#' @param tabindex Number for tabindex, default 0
#' @inheritDotParams shiny::h5
#'
Expand All @@ -81,16 +81,16 @@ h4_tabstop <- function(header, tabindex = 0, ...) {
#'
#' @examples
#' h5_tabstop("Heading")
h5_tabstop <- function(header, tabindex = 0, ...) {
# create header as typical header plus tabindex attribute
# ensures header will be stopped at when pressing keyboard tab
h5_tabstop <- h5(header, ...) %>%
h5_tabstop <- function(heading, tabindex = 0, ...) {
# create heading as typical heading plus tabindex attribute
# ensures heading will be stopped at when pressing keyboard tab
h5_tabstop <- h5(heading, ...) %>%
htmltools::tagAppendAttributes(`tabindex` = tabindex)
}

#' h6_tabstop
#'
#' @param header Heading text
#' @param heading Heading text
#' @param tabindex Number for tabindex, default 0
#' @inheritDotParams shiny::h6
#'
Expand All @@ -99,17 +99,17 @@ h5_tabstop <- function(header, tabindex = 0, ...) {
#'
#' @examples
#' h6_tabstop("Heading")
h6_tabstop <- function(header, tabindex = 0, ...) {
# create header as typical header plus tabindex attribute
# ensures header will be stopped at when pressing keyboard tab
h6_tabstop <- h6(header, ...) %>%
h6_tabstop <- function(heading, tabindex = 0, ...) {
# create heading as typical heading plus tabindex attribute
# ensures heading will be stopped at when pressing keyboard tab
h6_tabstop <- h6(heading, ...) %>%
htmltools::tagAppendAttributes(`tabindex` = tabindex)
}


#' nhs_card_tabstop
#'
#' @param header Card title
#' @param heading Card title
#' @param tabindex Number for tabindex, default 0
#' @param ... Card content
#'
Expand All @@ -118,9 +118,12 @@ h6_tabstop <- function(header, tabindex = 0, ...) {
#'
#' @examples
#' nhs_card_tabstop("A card", shiny::p("Some content"))
nhs_card_tabstop <- function(header, tabindex = 0, ...) {
nhs_card_tabstop <- function(heading, tabindex = 0, ...) {
# create nhs_card as typical nhs_card plus tabindex attribute
# ensures nhs_card will be stopped at when pressing keyboard tab
nhs_card_tabstop <- nhs_card(header, ...) %>%
htmltools::tagAppendAttributes(`tabindex` = tabindex)
htmltools::tagQuery(nhs_card(heading, ...))$
find(".nhsuk-card__heading")$
removeAttr("tabindex")$
addAttr("tabindex" = tabindex)$
allTags() # Exclude Linting
}
4 changes: 2 additions & 2 deletions man/h1_tabstop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/h2_tabstop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/h3_tabstop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/h4_tabstop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/h5_tabstop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/h6_tabstop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/nhs_card_tabstop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0fd3bff

Please sign in to comment.