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
tyluRp opened this issue Jan 23, 2020 · 2 comments
Closed

Unexpected behavior with waiter spinner with shinydashboard #43

tyluRp opened this issue Jan 23, 2020 · 2 comments
Labels
bug

Comments

@tyluRp
Copy link

@tyluRp tyluRp 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 added a commit that referenced this issue Jan 23, 2020
@JohnCoene
Copy link
Owner

@JohnCoene 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 closed this in 77adb8f Jan 23, 2020
@JohnCoene JohnCoene reopened this Jan 23, 2020
@JohnCoene JohnCoene added the bug label Jan 23, 2020
@tyluRp
Copy link
Author

@tyluRp tyluRp commented Jan 23, 2020

Working on my end, thanks! 👍

@JohnCoene JohnCoene closed this Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.