Hi all, I've got an issue with navigation within a shiny app that uses the bslib package. I have a button on a panel, that when clicked, should change the active panel in the app. It works fine, but there is a funky side effect where the tab link, which lives inside of a nav_menu() object, is displayed when the button is pressed. The sample shiny app code below demonstrates the problem. I am guessing that I'm just implementing this incorrectly out of ignorance, I'm pretty new to Shiny. What is the proper way to do this? This must be a common situation, but I'm not finding anything that speaks to it.
Cheers!
library(shiny)
library(bslib)
# Define UI for application that draws a histogram
ui <- page_navbar(
id = "master-page",
title = "My App",
nav_panel(title = "One", actionButton("do_test", label = "Click me")),
nav_spacer(),
nav_menu(
title = "Reports",
align = "right",
nav_panel(title = "Two", value="panel-2", p("Second page content.")),
nav_panel("Three", value="panel-3", p("Third page content.")),
)
)
# Define server logic required to draw a histogram
server <- function(input, output, session) {
observeEvent(input$do_test, {
nav_show("master-page", "panel-2", TRUE, session)
}, ignoreInit = TRUE)
}
# Run the application
shinyApp(ui = ui, server = server)