RinteRface/bs4Dash

menuItem with menuSubItem

ugurdar opened this issue · 1 comments

I try to add body to menuItem which have menuSubItem.
I'm using modules in shiny and I couldn't get input$sidebarItemExpanded to my server function.
Any idea?

  library(shiny)
  library(bs4Dash)
  
  shinyApp(
    ui = dashboardPage(
      header = dashboardHeader(skin = "dark"),
      body = dashboardBody(
        tabItems(
          tabItem(
            tabName= "tab1",
            p("test1")
          ),
          tabItem(
            tabName = "tab2",
            p("test2")
          )
        )
      ),
      sidebar = dashboardSidebar(
        skin = "light",
        inputId = "sidebarState",
        sidebarMenu(
          id = "sidebar",
          menuItem(
            tabName = "empty",
            text ="Item List 1"
          ),
          menuItem(
            tabName = "tab1",
            text = "Item List 2",
            icon = icon("bars"),
            startExpanded = TRUE,
            menuSubItem(
              text = "blabala",
              tabName = "tab2",
              icon = icon("circle")
            )
        )
      ),
      controlbar = dashboardControlbar(),
      footer = bs4DashFooter()
    )),
    server = function(input, output, session) {
     
  
})
  

Hi,

There is a typo in the dashboardSidebar parameter that should be id and not inputId:

library(shiny)
library(bs4Dash)

shinyApp(
    ui = dashboardPage(
        header = dashboardHeader(skin = "dark"),
        body = dashboardBody(
            tabItems(
                tabItem(
                    tabName= "tab1",
                    p("test1")
                ),
                tabItem(
                    tabName = "tab2",
                    p("test2")
                )
            )
        ),
        sidebar = dashboardSidebar(
            skin = "light",
            id = "sidebarState",
            sidebarMenu(
                id = "sidebar",
                menuItem(
                    tabName = "empty",
                    text ="Item List 1"
                ),
                menuItem(
                    tabName = "tab1",
                    text = "Item List 2",
                    icon = icon("bars"),
                    startExpanded = TRUE,
                    menuSubItem(
                        text = "blabala",
                        tabName = "tab2",
                        icon = icon("circle")
                    )
                )
            ),
            controlbar = dashboardControlbar(),
            footer = bs4DashFooter()
        )),
    server = function(input, output, session) {
        observe(print(input$sidebarItemExpanded))
        
    })