3

Is it possible to delay a tooltip and expire after a few seconds?

require(shiny)
require(shinyBS)

shinyApp(ui = fluidPage(
  shinyjs::useShinyjs(),
  bsTooltip(id = 'input', title = "Lets delay this appearing for 1s and force disappear after 5s", 
    placement = "bottom", trigger = "hover", options = list(delay = list(show=1000, hide=3000))),

  sidebarLayout(
    sidebarPanel(
      selectInput(inputId = 'input', label = 'input', choices = c('cats','dogs'))
    ),
    mainPanel()
  )
)
, server = function(input, output){})

enter image description here

geotheory
  • 22,624
  • 29
  • 119
  • 196

2 Answers2

4

shinyBS::bsTooltip fails to properly serialize nested options lists in https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/Tooltips_and_Popovers.R#L129

The options object ends up looking like { delay: "list(show = 1000, hide = 3000)" }

Unfortunately it looks like shinyBS isn't maintained anymore, or a fix would be worth submitting.

I'll suggest a workaround - using shinyBS::addTooltip which does serialize options correctly.

require(shiny)
require(shinyBS)

shinyApp(
  ui = fluidPage(
    # shinyjs::useShinyjs(),
    shinyBS:::shinyBSDep,

    sidebarLayout(
      sidebarPanel(
        selectInput(inputId = 'input', label = 'input', choices = c('cats','dogs'))
      ),
      mainPanel()
    )
  ),
  server = function(input, output, session) {
    addTooltip(session, id = 'input', title = "Lets delay this appearing for 1s and force disappear after 5s",
               placement = "bottom", trigger = "hover", options = list(delay = list(show=1000, hide=3000)))
  }
)

Or just using Bootstrap directly.

greg L
  • 4,034
  • 1
  • 19
  • 18
3

I used tipify. So my code was like:

tipify(
  element,
  title = "some title",
  options = list("delay" = 1000)
)

Problem was: delay has do be numeric but the function createTooltipOrPopoverOnUI (https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/Tooltips_and_Popovers.R) will put quotesigns arround all arguments:

options = paste0("{'", paste(names(options), options, sep = "': '", collapse = "', '"), "'}")

So i did this: im not proud of it but it worked:

options = list("delay': 1000, 'it" = "sucks")
Lukas
  • 314
  • 3
  • 14