navbarPage weird behaviour (with example code)

I'm having trouble with navbarPage ... see sample code 32 lines. Description follows.

library(shiny)
ui <- function(request) {
  fluidPage(
  navbarPage(bookmarkButton(label=""),id="navpage",selected="intro",
     navbarMenu("MENU",
      tabPanel("MenuRow1",id="intro",
          fluidRow(
            column(1),
            column(10, markdown("menu row 1") )
          )
      ),
      tabPanel("MenuRow2",id="refs",
          fluidRow(
             column(1),
             column(10, markdown("menu row 2") )
          )
      )
    ),
    tabPanel("PANEL",id="panel",
      fluidRow(
        column(12,imageOutput("gfimage",height=200))
      ),
      fluidRow(
        column(3,id="lrowb",markdown("panel row 2")),
        column(9, markdown("panel col 2") )
      )
    ) 
    ) 
  )
}
server <- function(ui,input, output,session) { }
shinyApp(ui = ui, server = server,enableBookmarking = "url")

When this page loads, it looks normal. Click on MENU and you can select MenuRow2. That's the problem starts. Having selected MenuRow2, you can't select MenuRow1. When you click the MENU, both options highlighted.

The problem is resolved if you click PANEL. After which the MENU button works fine.

I'm running on Ubuntu 20.04.3 LTS and Rstudio Version 1.3.1093

Looks like a clear bug to me, but I'd be delighted to find that the problem is with
my code :slight_smile:

This isn't a bug. The issue stems from the use of ids in the tabPanels. "id" isn't a valid argument for tabPanel, instead you should use the "value" argument. Therefore, according to the documentation for navbarPage, you should point to that value.

So your best option is to replace "id" with "value" in each of your tabPanels

Many thanks Michael, you have made my day :grinning:.

I need to read the docs more carefully! ... I know enough css/html to be thinking each tabpanel is a div and "should" have an id ... which I thought I was supplying.

Thanks again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.