ijlyttle / bsplus

Shiny and R Markdown addons to Bootstrap 3
http://ijlyttle.github.io/bsplus/
Other
146 stars 23 forks source link

delay attribute not fully working in bs_embed_tooltip #50

Closed dylancis closed 6 years ago

dylancis commented 6 years ago

as per bs doscs the delay attribute should accept: delay: { "show": 500, "hide": 100 } However trying the R equivalent failed(i.e. get ignored) while passing a single a number (hence applied to both show and hide works). Not sure If I am doing anything wrong with the syntax but JSONifying my argument looks file:

> toJSON(list("show" = 500, "hide" = 100), auto_unbox = T)
{"show":500,"hide":100} 

How do I apply different number to show and hide parameters please? Reproducible example (delay argument has no impact):

library(shiny)
library(bsplus)
library(shinyWidgets)

ui <- fluidPage(

  use_bs_tooltip(), # you need to call this function somewhere in your ui

  titlePanel("Hello Shiny!"),          
  sidebarLayout(
    sidebarPanel(
      shinyWidgets::materialSwitch(inputId = "testBS", label = "Test BS") %>%
            bs_embed_tooltip(title =  "this one is not okay!", 
                             trigger = "hover", delay = list("show" = 3500, "hide" = 50))
    ),
    mainPanel(

    )
  )
)

server <- function(input, output) {

}

shinyApp(ui, server)

While single number works fine:

library(shiny)
library(bsplus)
library(shinyWidgets)

ui <- fluidPage(

  use_bs_tooltip(), # you need to call this function somewhere in your ui

  titlePanel("Hello Shiny!"),          
  sidebarLayout(
    sidebarPanel(
      shinyWidgets::materialSwitch(inputId = "testBS", label = "Test BS") %>%
            bs_embed_tooltip(title =  "this one is okay!", 
                             trigger = "hover", delay = 2500)
    ),
    mainPanel(

    )
  )
)

server <- function(input, output) {

}

shinyApp(ui, server)
ijlyttle commented 6 years ago

I don't think that I am supporting lists to be translated as attributes - so I think this is where the problem is. Let me think a bit on how lists might be supported.

ijlyttle commented 6 years ago

Hi @dylancis,

I have added support for lists, so that your example should work. The core function, bs_attr(), now does this:

library("bsplus")

bs_attr(list("show" = 3500, "hide" = 50))
{"show":3500,"hide":50} 

I have pushed this change to master, can you install the dev version and see if this solves your problem?

Thanks,

Ian

dylancis commented 6 years ago

HI @ijlyttle , Works perfectly indeed! Many thanks for your very quick enhancement.

Dylan

ijlyttle commented 6 years ago

No problem, thanks for raising the issue!