rstudio / shinydashboard

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

Sidebar collapsed/expanded is reversed for small width/mobile #217

Closed bborgesr closed 7 years ago

bborgesr commented 7 years ago

This script:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(), 
  dashboardSidebar(),
  dashboardBody(
    textOutput("res")
  )
)

server <- function(input, output, session) {
  output$res <- renderText({
    if (input$sidebarCollapsed) {
      "Sidebar is collapsed"
    } else {
      "Sidebar is expanded"
    }
  })
}

shinyApp(ui, server)

works as expected in a laptop-sized screen:

screen shot 2017-05-21 at 9 40 22 pm screen shot 2017-05-21 at 9 40 29 pm

but it's reversed for small-width/mobile screens:

image 1 image

Note

This is a smaller problem than it appears because I suspect no-one (or very few people) are actually interested in the value of input$sidebarCollapsed. Rather, they just want the sidebar to look the same once they bookmark their app (which will happen as long as input$sidebarCollapsed has the same value, even if it is the wrong value). Nonetheless, this should be fixed.

bborgesr commented 7 years ago

Since this is due to CSS @media queries, I'm thinking of trying to detect them directly through Javascript, along these lines: http://zerosixthree.se/detecting-media-queries-with-javascript/