shinydashboard icon indicating copy to clipboard operation
shinydashboard copied to clipboard

Sidebar background color covers body background color when body height taller than screen height

Open gdurif opened this issue 3 years ago • 3 comments

Here is a MWE with collapsed boxes that can be expanded (the issue remains with long non collapsible boxes, c.f. below):

library(shiny)
library(shinydashboard)
library(stringi)
library(stringr)

ui <- dashboardPage(
    dashboardHeader(title = "Test"),
    dashboardSidebar("Empty sidebar"),
    dashboardBody(
        box(
            title = "box 1", 
            width = 12, 
            collapsible = TRUE,
            collapsed = TRUE,
            str_c(stri_rand_lipsum(5), collapse = "\n")
        ),
        box(
            title = "box 2", 
            width = 12, 
            collapsible = TRUE,
            collapsed = TRUE, 
            str_c(stri_rand_lipsum(5), collapse = "\n")
        ),
        box(
            title = "box 3", 
            width = 12, 
            str_c(stri_rand_lipsum(5), collapse = "\n")
        )
    ),
    skin = "black"
)

server <- function(input, output) { }

shinyApp(ui, server)

With the following result at the bottom of the page when expanding collapsed boxes:

shiny_issue

gdurif avatar Aug 11 '20 15:08 gdurif

With long content (static, not collapsible nor height varying), the part of the body that is outside the screen height is covered by the sidebar background.

Example:

library(shiny)
library(shinydashboard)
library(stringi)
library(stringr)

ui <- dashboardPage(
    dashboardHeader(title = "Test"),
    dashboardSidebar("Empty sidebar"),
    dashboardBody(
        box(
            title = "box 1", 
            width = 12,
            str_c(stri_rand_lipsum(5), collapse = "\n")
        ),
        box(
            title = "box 2", 
            width = 12,
            str_c(stri_rand_lipsum(5), collapse = "\n")
        ),
        box(
            title = "box 3", 
            width = 12, 
            str_c(stri_rand_lipsum(5), collapse = "\n")
        ),
        box(
            title = "box 4", 
            width = 12, 
            str_c(stri_rand_lipsum(5), collapse = "\n")
        ),
        box(
            title = "box 5", 
            width = 12, 
            str_c(stri_rand_lipsum(5), collapse = "\n")
        )
    ),
    skin = "black"
)

server <- function(input, output) { }

shinyApp(ui, server)

and result: shiny_issue2

gdurif avatar Aug 11 '20 15:08 gdurif

You can wrap the boxes in a fluidRow to avoid the above issue:

library(shiny)
library(shinydashboard)
library(stringi)
library(stringr)

ui <- dashboardPage(
  dashboardHeader(title = "Test"),
  dashboardSidebar("Empty sidebar"),
  dashboardBody(
    fluidRow(
    box(
      title = "box 1", 
      width = 12,
      str_c(stri_rand_lipsum(5), collapse = "\n")
    ),
    box(
      title = "box 2", 
      width = 12,
      str_c(stri_rand_lipsum(5), collapse = "\n")
    ),
    box(
      title = "box 3", 
      width = 12, 
      str_c(stri_rand_lipsum(5), collapse = "\n")
    ),
    box(
      title = "box 4", 
      width = 12, 
      str_c(stri_rand_lipsum(5), collapse = "\n")
    ),
    box(
      title = "box 5", 
      width = 12, 
      str_c(stri_rand_lipsum(5), collapse = "\n")
    ))
  ),
  skin = "black"
)

server <- function(input, output) { }

shinyApp(ui, server)

ismirsehregal avatar Aug 19 '20 07:08 ismirsehregal

@ismirsehregal thank you very much

gdurif avatar Aug 19 '20 08:08 gdurif