Is there a way to create a popover/tooltip in a Shiny app that automatically appears when users switch to a specific tab containing a data table? I have tried using the shinybs
package to create a popover that shows on click or hover, but I need it to appear without any interaction. I believe the trigger = "manual"
option might help, but I'm not sure how to implement a manual trigger. I'm open to alternative solutions that achieve the same outcome.
Additionally, I would like the popover to be positioned in a way that it points to a particular row in the data table. In the past, I have used the rowCallback = JS(rowCallback)
parameter with the shinyjs
package to add hover-over tooltips to rows, but I'm unsure if this can be modified to show tooltips without hovering.
Lastly, I need a way to close the popover/tooltip. Any guidance on this would be greatly appreciated.
Below is a basic example with a shinybs popover triggered by a click (which is not the desired behavior):
library(shiny)
library(shinyBS)
library(DT)
data <- as.data.frame(rbind(c(1,2,3), c(4,5,6)))
colnames(data) <- c("Var1", "Var2", "Var3")
ui <- navbarPage(
title = "Title", id = "navbar",
tabsetPanel(id="tabs",
tabPanel(value = "tab1", title = "Tab1",
actionButton("action1", "Switch tabs")
),
)
)
server <- function(input, output, session) {
observeEvent(input$action1, {
insertTab(inputId = "tabs", target = "tab1", select=T,
tabPanel(value = "tab2", title = "Tab2",
dataTableOutput("table1"),
bsPopover(id="table1", title="A popover",
placement = "bottom", trigger = "click")
)
)
})
output$table1 <- renderDataTable({
datatable(data)
})
}
shinyApp(ui, server)