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

Initially Collapsed Box Fails to Render Content when Expanded #42

Closed
phillc73 opened this issue Apr 26, 2015 · 5 comments
Closed

Initially Collapsed Box Fails to Render Content when Expanded #42

phillc73 opened this issue Apr 26, 2015 · 5 comments

Comments

@phillc73
Copy link

phillc73 commented Apr 26, 2015

If a box is collapsed on initial load, the content then fails to load when the box is subsequently expanded.

Example problem code:

library("shinydashboard")

header <- dashboardHeader()

sidebar <- dashboardSidebar(
  sidebarMenu(
    menuItem("Inputs", icon = icon("bar-chart-o"), tabName = "tabOne"
    )
  )
)

body <- dashboardBody(
  tabItems(
    tabItem("tabOne",
            box(title = "Test Box One", 
                width = 12,
                status = "success", 
                solidHeader = TRUE, 
                collapsible = TRUE,
                collapsed = TRUE,
                verbatimTextOutput("boxOneText")
            )
    )
  )
)

shinyApp(
  ui = dashboardPage(header, sidebar, body),
  server = function(input, output) {

    output$boxOneText <- renderText({
      paste("A test designed to provoke an emotional response")
    })

  }
)

However, the following code, with the box expanded on initial load, works fine and even after collapsing and expanding the box. The text continues to render:

library("shinydashboard")

header <- dashboardHeader()

sidebar <- dashboardSidebar(
  sidebarMenu(
    menuItem("Inputs", icon = icon("bar-chart-o"), tabName = "tabOne"
    )
  )
)

body <- dashboardBody(
  tabItems(
    tabItem("tabOne",
            box(title = "Test Box One", 
                width = 12,
                status = "success", 
                solidHeader = TRUE, 
                collapsible = TRUE,
                collapsed = FALSE,
                verbatimTextOutput("boxOneText")
            )
    )
  )
)

shinyApp(
  ui = dashboardPage(header, sidebar, body),
  server = function(input, output) {

    output$boxOneText <- renderText({
      paste("A test designed to provoke an emotional response")
    })

  }
)

The problem only seems to manifest itself when boxes are initially collapsed.

I have shinydashboard 0.40 installed.

@name-name
Copy link

Just ran into the same problem and had to revert to version 0.3.1 because of this :-(
(Well, or start the boxes as collapsed=FALSE)

@jcheng5
Copy link
Member

jcheng5 commented May 20, 2015

This sounds like maybe just a shown or hidden event needs to be triggered?

@wch wch closed this as completed in 73f6027 Jun 3, 2015
@wch
Copy link
Contributor

wch commented Jun 3, 2015

Yup, it just needed those events to be triggered.

For future reference, here's a streamlined test app:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Inputs", icon = icon("bar-chart-o"), tabName = "tabOne"
      )
    )
  ),
  dashboardBody(
    tabItems(
      tabItem("tabOne",
        box(title = "Test Box One", 
          status = "success", 
          solidHeader = TRUE, 
          collapsible = TRUE,
          collapsed = TRUE,
          plotOutput("plot", height = 250),
          verbatimTextOutput("boxOneText")
        ),
        box(
          actionButton("go", "Go")
        )
      )
    )
  )
)

server <-  function(input, output) {
  output$plot <- renderPlot({
    cat(paste("plotting", input$go, "\n"))
    plot(rnorm(1 + input$go), rnorm(1 + input$go))
  })
  output$boxOneText <- renderText({
    paste("Go counter:", input$go)
  })
}

shinyApp(ui, server)

@happyshows
Copy link

@wch
Currently, I am wrapping a DT table inside a box. If a user click a cell, it will trigger an cell_clicked observe event to do certain operation. Now I want to put a line to 'collapse the box' at the end of observe event.
However, if I setup a session variable and use it to trigger a redraw of the box, the dt table will disappear. (I guess shiny does not allow an object to be defined twice??)

Is there any function to update the status of collapse? something like updateTabsetPanel? I'm open to alternatives too.

server.R
sess$boxFlag <- FALSE

observeEvent(input$dt_summary_cell_clicked,{
isolate({
if(length(cellValue <-input$dt_summary_cell_clicked) == 0) return(invisible())
sess$boxFlag <- TRUE
})
})

ui.R
output$ui_box <- renderUI({
flag <- sess$boxFlag

isolate({
box(title = 'Summary', width = 12, status = 'primary', collapsible = TRUE, collapsed = flag,
dataTableOutput('dt_summary')
)
})
})

Let me know if more clarification is required.

dmpe added a commit to dmpe/shinydashboard that referenced this issue Dec 8, 2015
dmpe added a commit to dmpe/shinydashboard that referenced this issue Jan 26, 2016
delete `interactive()` because tests are in Rignore
add comments
fix tabItems issue
comment repro issues
fix version, bump both package further ahead and make sure that rstudio#42 is not repro on my pc
dmpe added a commit to dmpe/shinydashboard that referenced this issue Jan 31, 2016
delete `interactive()` because tests are in Rignore
add comments
fix tabItems issue
comment repro issues
fix version, bump both package further ahead and make sure that rstudio#42 is not repro on my pc
@DarioBoh
Copy link

I have the same problem but when rendering on sidebarMenu, am I doing anything wrong?


library('shiny')
library("shinydashboard")

header <- dashboardHeader()

sidebar <- dashboardSidebar(
  sidebarMenu(
    menuItem("Inputs", icon = icon("bar-chart-o"), tabName = "tabOne",
             uiOutput('mymenu')
    )
  )
)

body <- dashboardBody(
  h3('nothing here')
)

shinyApp(
  ui = dashboardPage(header, sidebar, body),
  server = function(input, output) {


    output$mymenu <- renderUI({

      checkboxGroupInput('mymenu', 'lettersMenu',
                         letters[1:5],
                         letters[1:5])
    })
  }
)

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

6 participants