Skip to content

Commit

Permalink
updated dropMenu bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Apr 30, 2020
1 parent 7fd2f05 commit d942e28
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 29 deletions.
24 changes: 10 additions & 14 deletions R/drop-menu.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#' @param maxWidth Determines the maximum width of the menu.
#' @param options Additional options, see \code{\link{dropMenuOptions}}.
#'
#' @seealso \link[=drop-menu-interaction]{dropMenu interaction} for functions
#' and exemples to interact with \code{dropMenu} from server.
#'
#' @return A UI definition.
#' @export
#'
Expand Down Expand Up @@ -60,16 +63,8 @@ dropMenu <- function(tag, ...,
stop("dropMenu: 'tag' must have an Id.")
}

content <- htmltools::doRenderTags(tags$div(
id = paste0(tag$attribs$id, "_content"),
style = sprintf("padding: %s;", validateCssUnit(padding)),
...
))
content <- gsub(pattern = ">[[:space:]]*<", replacement = "><", x = content)

config <- list(
options = list(
content = content,
arrow = arrow,
theme = theme,
trigger = trigger,
Expand All @@ -92,11 +87,12 @@ dropMenu <- function(tag, ...,
id = paste0(tag$attribs$id, "_dropmenu"),
`data-target` = tag$attribs$id,
`data-content` = paste0(tag$attribs$id, "_content"),
`data-remove` = paste0(tag$attribs$id, "_remove"),
`data-template` = paste0(tag$attribs$id, "-template"),
tag,
tags$div(
style = "display: none;",
id = paste0(tag$attribs$id, "_remove"),
style = sprintf("padding: %s;", validateCssUnit(padding)),
id = paste0(tag$attribs$id, "-template"),
...
),
tags$script(
Expand All @@ -106,11 +102,12 @@ dropMenu <- function(tag, ...,
)
)
htmltools::attachDependencies(
x = dropTag,
x = attachShinyWidgetsDep(dropTag),
value = list(
html_dependencies_popper(),
html_dependencies_tippy()
)
),
append = TRUE
)
}

Expand Down Expand Up @@ -230,8 +227,7 @@ html_dependencies_tippy <- function() {
src = list(href = "shinyWidgets/tippy", file = "assets/tippy"),
package = "shinyWidgets",
script = c(
"dist/tippy-bundle.iife.min.js",
"drop-menu-bindings.js"
"dist/tippy-bundle.iife.min.js"
),
stylesheet = c(
"dist/themes.min.css",
Expand Down
Loading

0 comments on commit d942e28

Please sign in to comment.