Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Part of sidebar can't be hidden when the screen is narrow after sidebar width setting #163

Closed
PeiranYu opened this issue Oct 5, 2016 · 2 comments

Comments

@PeiranYu
Copy link

PeiranYu commented Oct 5, 2016

The way to set sidebar width as detailed here (https://rstudio.github.io/shinydashboard/appearance.html#sidebar-width) works fine when the screen is wide, but it doesn't work very well when the screen is narrow. For example, it looks like this when the screen becomes narrow if I don't set the sidebar width.
image
However, it looks like this when I set the sidebar width.
image
Note, the sidebar is supposed to be hidden in both cases, but as you can see, part of the sidebar is still there when the screen is narrower (it is not there when the scree is wider) after I set the sidebar width, and it covers some of the elements in dashboard body. Could it be fixed?

Thank you.

@PeiranYu PeiranYu changed the title Part of sidebar can't be hidden when the screen is narrow after Shiny Dashboard sidebar width setting Part of sidebar can't be hidden when the screen is narrow after sidebar width setting Oct 5, 2016
@sgrubsmyon
Copy link

To me, it looks like the problem is that shinydashboard sets custom CSS rules, but they only apply for wider screens. Setting width of the sidebar and titleWidth of the header to 100px, I see with my browser's web inspector the following CSS:

# in file shiny.css
@media (min-width: 768px) {
        .content-wrapper,
        .right-side,
        .main-footer {
          margin-left: 100px;
        }
        .main-sidebar,
        .left-side {
          width: 100px;
        }
      }

If these rules were not within the @media (min-width: 768px) clause, then it would probably work.

As a workaround, I did:

  extraStyle <- tags$head(
    tags$style(HTML(paste(
      ".main-sidebar,",
      ".left-side {",
        "width: 100px;",
      "}"))
    )
  )

  body <- tabItems(
    # First tab content
    tabItem(
      tabName = "tab1",
      ...
    ),
    ...
  )

  dashboardPage(
    ...
    dashboardBody(extraStyle, body)
  )

which sets the CSS rules unconditionally and it works as intended.

@bborgesr
Copy link
Contributor

Thank you both and I'm sorry for the very late reply. This has been fixed in #204. The updated code is now in the development version of shinydashboard (to install in R, do devtools::install_github("rstudio/shinydashboard")), which will be released to CRAN within the next couple of weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants