rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
893 stars 298 forks source link

When using startExpanded = TRUE the arrow icon isn't pointing downwards #382

Open ismirsehregal opened 2 years ago

ismirsehregal commented 2 years ago

When using the startExpanded parameter for childfull menuItems the arrow icon is using fa-angle-left when first invoking the app (Maybe this is because the parent li.treeview tag isn't getting updated with class "active"?). Instead it should point downwards (using fa-angle-down), to be aligned with the behaviour when clicking the menuItem manually:

Animation

Example code:

library(shiny)
library(shinydashboard)

ui <- function(req) {
  dashboardPage(
    dashboardHeader(title = "Simple tabs"),
    dashboardSidebar(
      sidebarMenu(
        id = "sidebarItemSelected",
        menuItem(
          "Childfull menuItem 1",
          menuItem(
            "Childless menuItem 1",
            tabName = "childlessTab1",
            icon = icon("dashboard"),
            selected = TRUE
          ),
          # fileInput("upload", "Upload"),
          bookmarkButton(),
          expandedName = "childfullMenuItem1",
          startExpanded = TRUE
        ),
        menuItem(
          "Childfull menuItem 2",
          menuItem(
            "Childless menuItem 2",
            icon = icon("th"),
            tabName = "childlessTab2",
            badgeLabel = "new",
            badgeColor = "green"
          ),
          expandedName = "childfullMenuItem2"
        )
      )
    ),
    dashboardBody(tabItems(
      tabItem(tabName = "childlessTab1",
              h2("Dashboard tab content")),
      tabItem(tabName = "childlessTab2",
              h2("Widgets tab content"))
    ))
  )
}

server <- function(input, output, session) {
  observe({
    cat(
      paste(
        "\nsidebarItemSelected:",
        input$sidebarItemSelected,
        "\nsidebarItemExpanded:",
        input$sidebarItemExpanded,
        "\nsidebarCollapsed:",
        input$sidebarCollapsed,
        "\n"
      )
    )
  })
}

shinyApp(ui, server, enableBookmarking = "url")
ghost commented 2 years ago

I am running into the same problem if I select another menuItem before first collapsing the current menuItem.