rstudio/shiny

Inconsistent behavior of busy indicators for different outputs: `tableOutput()`, `reactableOutput()`, `textOutput()`

gsmolinski opened this issue · 3 comments

System details

Output of sessionInfo():

R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19044)

Matrix products: default


locale:
[1] LC_COLLATE=Polish_Poland.utf8  LC_CTYPE=Polish_Poland.utf8   
[3] LC_MONETARY=Polish_Poland.utf8 LC_NUMERIC=C                  
[5] LC_TIME=Polish_Poland.utf8    

time zone: Europe/Warsaw
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] reactable_0.4.4 shiny_1.9.1    

loaded via a namespace (and not attached):
 [1] cli_3.6.3         rlang_1.1.4       promises_1.3.0   
 [4] jsonlite_1.8.8    xtable_1.8-4      htmltools_0.5.8.1
 [7] httpuv_1.6.15     reactR_0.6.0      sass_0.4.9.9000  
[10] rsconnect_1.3.1   crosstalk_1.2.1   jquerylib_0.1.4  
[13] fastmap_1.2.0     yaml_2.3.10       lifecycle_1.0.4  
[16] memoise_2.0.1     compiler_4.4.1    htmlwidgets_1.6.4
[19] Rcpp_1.0.13       rstudioapi_0.16.0 later_1.3.2      
[22] digest_0.6.36     R6_2.5.1          magrittr_2.0.3   
[25] bslib_0.8.0       tools_4.4.1       withr_3.0.1      
[28] mime_0.12         cachem_1.1.0 

Example application or steps to reproduce the problem

Run the code below and click buttons, you should see:

  1. For table output - no busy indicator at all, output is just faded.
  2. For reactable output - busy indicator is not displayed first time, but is displayed when button is clicked more than once.
  3. For text output - busy indicator is displayed for each click.
library(shiny)
library(reactable)

ui <- fluidPage(
  useBusyIndicators(),
  actionButton("run_tbl", "Run table"),
  actionButton("run_reactable", "Run reactable"),
  actionButton("run_text", "Run text"),
  textOutput("text"),
  fluidRow(
    column(6, tableOutput("tbl")),
    column(6, reactableOutput("r_tbl"))
  )
)

server <- function(input, output, session) {
  
  text_r <- reactive({
    Sys.sleep(3)
    "test"
  }) |> 
    bindEvent(input$run_text)
  
  iris_r <- reactive({
    Sys.sleep(3)
    iris
  }) |> 
    bindEvent(input$run_tbl)
  
  mtcars_r <- reactive({
    Sys.sleep(3)
    mtcars
  }) |> 
    bindEvent(input$run_reactable)
  
  output$text <- renderText({
    text_r()
  })
  
  output$tbl <- renderTable({
    iris_r()
  })
  
  output$r_tbl <- renderReactable({
    reactable(mtcars_r())
  })
  
}

shinyApp(ui, server)

Describe the problem in detail

I didn't check other outputs. For me it looks like a bug or at least lack of the feature - I would expect that (1) busy indicators will work the same way no matter what output is used; (2) busy indicator will be visible each time button is clicked. I have checked this on RStudio Viewer, Chrome and Edge.

As a side note - I also see that busy indicator is not faded on reactable output, but is faded on text output when button is clicked second or more times (i.e. is not faded only for the first time). I think it shouldn't be faded.