dreamRs / shinyWidgets

shinyWidgets : Extend widgets available in shiny
https://dreamrs.github.io/shinyWidgets/
GNU General Public License v3.0
833 stars 153 forks source link

arrow down up incorrect behavior when using shinydashboardPlus menutItem and pretttyToggle #414

Open xtimbeau opened 3 years ago

xtimbeau commented 3 years ago

Here is a small reprex of a prettyToggle (really pretty btw) strange behavior when used with whinydashboardplus. As you can see toggling the prettytoggle is toggling the menu open/close icon on the right. It works correctly with shinydashboard, incorrectly with shinydashboardPlus.

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyWidgets)

ui  <- dashboardPage(
  title= "a title",
  header=dashboardHeader(title= "a title"),
  sidebar=dashboardSidebar(
    width="360px",
    sidebarMenu(
      id = "tabs",
      menuItem("Buttons", tabName = "dashboard", icon = icon("dashboard"),
               prettyToggle(inputId="pretty_tgl_1", label_on="on", label_off="off")))),
  body=dashboardBody(
    box(
      title = textOutput("box_state"),
      id = "mybox",
      background = "maroon", 
      gradient = TRUE,
      collapsible = TRUE,
      closable = TRUE,
      textOutput("pretty_tgl_1"),
      width=12)))

server <- function(input, output, session) {

  observeEvent(input$pretty_tgl_1, {
    output$pretty_tgl_1 <- renderText(input$pretty_tgl_1)
  })
}

shinyApp(
    ui = ui,
    server = server
  )
pvictor commented 3 years ago

Hello,

From documentation menuSubItems dhould be passed to menuItem, this is a rather unusual case and I don't have an explanation on what is causing the difference between shinydashboard and shinydashboardPlus...

Victor