bs4Dash
bs4Dash copied to clipboard
Subitems in sidebarMenuOutput not collapsing/expanding properly
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:
- Run the app
- Click menuItem. Everything works as expected.
- Click update button. Sidebar menu is rerendered.
- 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.
I started to have a look. It seems that the treeview plugin cannot be re-initializated properly.