shinycssloaders icon indicating copy to clipboard operation
shinycssloaders copied to clipboard

Infinite spinner on req(cancelOutput = TRUE)

Open bartekch opened this issue 3 years ago • 0 comments

When there is an output with spinner and somewhere in its reactive dependencies the processing is stopped by req(..., cancelOutput = TRUE), spinner will never disappear. In the following app this is happening when the box is unchecked and data is recalculated. The previous output is still there, but the spinner won't hide back.

library(shiny)
library(shinycssloaders)

shinyApp(
  ui = basicPage(
    checkboxInput("is_correct", "Is data correct?", TRUE),
    actionButton("recalculate", "Recalculate data"),
    
    shinycssloaders::withSpinner(
      tableOutput("table")
    )
  ),
  
  server = function(input, output, session) {
    output$table <- renderTable({
      input$recalculate
      Sys.sleep(1)
      req(isolate(input$is_correct), cancelOutput = TRUE)
      data.frame(x = rnorm(5))
    })
  }
)

I guess it could not be trivial to fix, but anyway, it would be nice to have spinner hidden in such cases.

bartekch avatar Feb 25 '22 15:02 bartekch