Nested bslib nav_menu within page_navbar

353 views Asked by At

I'm looking around how I could update my shiny dashboard built with {bs4Dash} using the latest production version of {bslib} (0.5.1).

However, it seems that nesting a nav_menu inside a nav_menu in the page_navbar() layout is not working : when we click on the nested nav_menu to deploy it, it simply closes the parent nav_menu.

Here's a reprex :

library(bslib)
library(shiny)

shinyApp(
  page_navbar(
    title = "Nested nav_menu attempt",
    id = "nav",
    nav_menu(
      title = "Parent nav_menu",
      value = "First item",
      nav_panel("First item", "first item text"),
      nav_menu(title = "Nested nav_menu",
               nav_panel("Second nested item", "second item text"),
               nav_panel("Third nested item", "third item text"))
    ),
    sidebar = sidebar()
  ),
  server = function(...) {
    # no server logic required
  }
)

Any idea on how to make this work ? If it's not possible yet, any clean & simple idea for a workaround ? I cannot have too many items horizontally in my navbar, which is why I think nesting was a good option for me. Inserting any other parent holder than bslib::nav_menu or shiny::navbarMenu won't work.

Thanks !

0

There are 0 answers