Skip to content

Weird behavior when using navbarMenu() and bs4SidebarMenu() simultaneously #394

@lanceupton

Description

@lanceupton

In the below reprex, the shiny app should track "page" via the navbarTab() items in the navbar, and it should track "tab" via the bs4TabItem() items in the sidebar. The app prints the value of each of these as you make selections.

As you make selections in either section, both inputs get the same value. It looks like the input bindings are not separated (even though the id passed to the container functions are different).

library(shiny)
library(bs4Dash)
shinyApp(
  ui = bs4DashPage(
    header = bs4DashNavbar(
      navbarMenu(
        id = "page",
        navbarTab(text = "Page 1", tabName = "page1"),
        navbarTab(text = "Page 2", tabName = "page2")
      )
    ),
    sidebar = bs4DashSidebar(
      id = "sidebar",
      bs4SidebarMenu(
        id = "tab",
        menuItem(text = "Tab 1", tabName = "tab1"),
        menuItem(text = "Tab 2", tabName = "tab2")
      )
    ),
    body = bs4DashBody(bs4TabItems(
      bs4TabItem(tabName = "page1", "PAGE 1"),
      bs4TabItem(tabName = "page2", "PAGE 2")
    )),
    footer = bs4DashFooter()
  ),
  server = function(input, output, session) {
    observe(message("page: ", input$page))
    observe(message("tab: ", input$tab))
  })
}

Using the following package versions:
bs4Dash_2.3.4, shiny_1.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions