bs4Dash icon indicating copy to clipboard operation
bs4Dash copied to clipboard

Subitems in sidebarMenuOutput not collapsing/expanding properly

Open DavidBarke opened this issue 4 years ago • 1 comments

Reproducible example:
library(shiny)
library(bs4Dash)

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    sidebar = dashboardSidebar(sidebarMenuOutput("sidebar_menu")),
    body = dashboardBody(
      shiny::actionButton("update", "Update")
    )
  ),
  server = function(input, output) {
    sidebar_menu_r <- reactive({
      input$update
      sidebarMenu(
        menuItem(
          text = "Item",
          menuSubItem(
            text = "Subitem"
          )
        )
      )
    })

    output$sidebar_menu <- renderMenu({
      sidebar_menu_r()
    })
  }
)

Steps to reproduce this issue:

  1. Run the app
  2. Click menuItem. Everything works as expected.
  3. Click update button. Sidebar menu is rerendered.
  4. Click menuItem. Treeview gets expanded but won't collapse on further clicks.

Suspected problem: Every time the sidebar menu is rendered an additional click event handler is added to .has-treeview > .nav-link.

DavidBarke avatar Feb 06 '21 14:02 DavidBarke

I started to have a look. It seems that the treeview plugin cannot be re-initializated properly.

DivadNojnarg avatar Feb 12 '21 10:02 DivadNojnarg