daattali / shinycssloaders

⌛ Add loading animations to a Shiny output while it's recalculating
https://daattali.com/shiny/shinycssloaders-demo/
Other
395 stars 45 forks source link

Bug with new full-page loader: calling showPageSpinner() more than once causes multiple page spinners to exist #92

Closed daattali closed 6 days ago

daattali commented 6 days ago

This is problematic because hidePageSpinner() assumes there is only one on the page, and removes only one. The problem can be seen with this code:

library(shiny)

ui <- fluidPage()

server <- function(input, output, session) {
  shinycssloaders::showPageSpinner()
  Sys.sleep(0.5)
  shinycssloaders::showPageSpinner(color = "red")
  Sys.sleep(0.5)
  shinycssloaders::hidePageSpinner()
}

shinyApp(ui, server)

Even though hide is called at the end, there is still a spinner on the page.