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

Unexpected behavior with waiter spinner with shinydashboard #43

Closed
tylerlittlefield opened this issue Jan 23, 2020 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@tylerlittlefield
Copy link

tylerlittlefield commented Jan 23, 2020

Hi @JohnCoene !

I am trying to add a loading screen to a datatable that is inside a shinydashboard box. However, the spinner looks like a really small box rather than the actual spinner. This seems to go away if I manually assign a spinner. A reproducible example below:

library(shiny)
library(shinydashboard)
library(waiter)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    use_waiter(),
    actionButton("draw", "draw plot"),
    box(plotOutput("plot"))
  )
)

server <- function(input, output) {
  w <- Waiter$new(id = "plot")
  # w <- Waiter$new(id = "plot", html = spin_half())
  
  dataset <- reactive({
    input$draw
    w$show()
    Sys.sleep(3)
    w$hide()
    
    runif(100)
  })
  
  output$plot <- renderPlot(plot(dataset()))
}

shinyApp(ui, server)
@JohnCoene
Copy link
Owner

JohnCoene commented Jan 23, 2020

Hi Tyler, thank you for reporting this!

Indeed one of the CSS classes clashed with shinydashboard and thus instead of showing the spinner was showing the box just like box() funnily enough. I pushed a fix, you can reinstall the package from Github and it should work.

# install.packages("remotes")
remotes::install_github("JohnCoene/waiter")

Note that if the id passed is that of a rendered element, like a plot, a table, a renderUI, then waiter automatically hides the loading screen when it is re-rendered, see the "partial" doc entry.

library(shiny)
library(shinydashboard)
library(waiter)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    use_waiter(),
    actionButton("draw", "draw plot"),
    box(plotOutput("plot"))
  )
)

server <- function(input, output) {
  w <- Waiter$new(id = "plot")
  
  dataset <- reactive({
    input$draw
    w$show()
    Sys.sleep(3)

    # hides automatically 
    #w$hide()
    
    runif(100)
  })
  
  output$plot <- renderPlot(plot(dataset()))
}

shinyApp(ui, server)

waiter-shinydash

Let me know if this works so I can close the issue. Thanks again!

@JohnCoene JohnCoene reopened this Jan 23, 2020
@JohnCoene JohnCoene added the bug Something isn't working label Jan 23, 2020
@tylerlittlefield
Copy link
Author

Working on my end, thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants