Skip to content

Commit

Permalink
change ns of externally passed input elements in f7Login
Browse files Browse the repository at this point in the history
  • Loading branch information
DivadNojnarg committed May 24, 2024
1 parent 6030464 commit 13593c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/f7Login.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ cancellable = FALSE) {
submitBttn
)
}

items <- list(...)
if (length(items) > 0) items <- change_id(items, ns)

Check warning on line 47 in R/f7Login.R

View check run for this annotation

Codecov / codecov/patch

R/f7Login.R#L47

Added line #L47 was not covered by tests

shiny::tags$div(
id = sprintf("%s-login", id),
Expand All @@ -68,7 +71,7 @@ cancellable = FALSE) {
label = "Password",
placeholder = "Your password here"
),
...
items
),
btnUI,
if (!is.null(footer)) {
Expand Down
16 changes: 16 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,19 @@ create_app_link <- function(
`data-external` = "1"
)
}

#' Change tags ids
#'
#' Changes the id of the shiny tags
#' and any nested element.
#'
#' @keywords internal
#' @noRd
change_id <- function(items, ns) {
lapply(items, \(item) {
full_ns <- ns(character(0))
tmp <- strsplit(as.character(item), "\n")[[1]]
outer_ns <- strsplit(full_ns, "-")[[1]][1]
shiny::HTML(paste(gsub(sprintf("%s", outer_ns), full_ns, tmp), collapse = "\n"))

Check warning on line 250 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L246-L250

Added lines #L246 - L250 were not covered by tests
})
}

0 comments on commit 13593c0

Please sign in to comment.