0

I have a shiny app with popovers that contain useful information on interpretation of plot output. However, i have to close the popover "manually" everytime. Otherwise the popover of tab "dash1" will stay even if i switch to tab "dash2".

library(shiny)
library(bs4Dash)



ui <- dashboardPage(
  
  dashboardHeader(title = "Dashboard",
                  titleWidth = 550,
                  disable= FALSE,
                  sidebarIcon = NULL
  ),
  
  dashboardSidebar(
    
    
    sidebarMenu(
      menuItem("dash1", tabName= "dashboard1"),
      menuItem("dash2", tabName= "dashboard2")
      
    )
  ),
  
  dashboardBody(
    tabItems(
      
      tabItem(tabName = "dashboard1",
              
              box(
                title = "Interpretation",
                popover(
                  actionButton("goButton", "Click here"),
                  title = "Important information",
                  placement = "right",
                  content = "popover text bla bla"
                  
                )
              )
      ),
      
      tabItem(tabName = "dashboard2",
              
              box(
                title = "Interpretation",
                popover(
                  actionButton("goButton2", "Click here"),
                  title = "Important information",
                  placement = "right",
                  content = "popover text bla bla"
                  
                )
              )
           )
      )
  )
)


server <- function(input, output) {
  
}


shinyApp(ui = ui, server = server)

How can i prevent this "behavior"? Do i necessarily have to specify addPopover and removePopover within the server part?

Philipp Schulz
  • 131
  • 1
  • 8
  • Have you try `conditionalPanel()` ? https://shiny.rstudio.com/reference/shiny/latest/conditionalpanel – phili_b Jan 03 '23 at 17:44
  • Thank you. I havent done so because i was not aware of this option. I am not sure if this really helps because i want the basic input element (i.e. the closed popover) to be shown permanently. Only the popover text should close again when i switch to another tab. – Philipp Schulz Jan 04 '23 at 07:24
  • Go to debug (F12) to see what happens in the html source: I understand better your problem when I see it, but I don't understand completely what do you want . Maybe read https://getbootstrap.com/docs/4.0/components/popovers/ can help you (linked in the help of `bs4Dash::popover()`) . But when I read it, yes it seems that you should have to use `removePopover()` if you don't want reinvent the wheel. – phili_b Jan 04 '23 at 10:20

1 Answers1

0

I solved the problem with the help of this issue:

Display Text only on hover

What i need is a tooltip rather than a popover.

Philipp Schulz
  • 131
  • 1
  • 8