bs4Dash icon indicating copy to clipboard operation
bs4Dash copied to clipboard

Dynamic sidebarMenu lost functionality

Open analytichealth opened this issue 2 years ago • 0 comments

Using a dynamic sidebarMenu loses some functionality after update. If you run this code, at first you can click on 'Menu item' to repeatedly hide and show 'Sub Menu 0'. However, if you then click on the 'Update Sidebar' button you lose the functionality to hide and show the Sub Menu.

bs4Dash version: 2.1.0 R version: 4.0.3

library(bs4Dash)
ui <- dashboardPage(
  dashboardHeader(title = "Dynamic sidebar"),
  dashboardSidebar(
    sidebarMenuOutput("menu")
  ),
  dashboardBody(
    actionButton("go", "Update sidebar")
  )
)
server <- function(input, output) {
  r = reactiveVal(0)
  observeEvent(input$go, {
    r(r() + 1)
  })
  output$menu <- renderMenu({
    sidebarMenu(
      menuItem("Menu item", icon = icon("calendar"),
               menuSubItem(paste0("Sub Menu ", r())))
    )
  })
}
shinyApp(ui, server)
}

analytichealth avatar Sep 27 '22 15:09 analytichealth