Adding popover to bsCollapsePanel in Shiny

75 Views Asked by At

I have a Shiny application which has collapse panels. I want to be able to add a popover to the collapse panel the same way I have added to the textInput(id = 'myText')

library(shiny)
library(shinyBS)

ui <- fluidPage(
  shinyBS::bsCollapse(
    id = "all_panels", 
    open = c("My Panel"),
    shinyBS::bsCollapsePanel(
      title = "My Panel",
      textInput(inputId = "myText", label = "Some Label") %>% popify(title = "A Title", trigger = "hover", placement = "top", content = "Popover Content")
    ) %>% popify(title = "A Title", trigger = "hover", placement = "bottom", content = "Popover Content")
  )
)

server <- function(input, output, session) {
  
}

shinyApp(ui, server)

I am getting the following error:

Error in if (getAttribs(panels[[i]])$value %in% open) { : 
  argument is of length zero

If I remove the bsCollapse(...) and have the bsCollapsePanel(...) on it's own I do not get the error and the popup shows as intended. But I then loose the capability of of opening and closing collapse panels by referring to their title.

I have tried adding an id = 'myPanel' parameter to bsCollapsePanel() and then on the server() side added:

addPopover(
    session = session,
    id = "myPanel",
    title = "SomeTitle",
    content = "SomeContent",
    trigger = "click"
  )

but that didn't work either.

Any help is appreciated.

0

There are 0 best solutions below