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

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

Open
gsmolinski opened this issue Aug 6, 2024 · 3 comments · May be fixed by #4172

Comments

@gsmolinski
Copy link
Contributor

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.

@AkedoMakona
Copy link

Similarly, no busy indicators is displayed at all for visNetworkOutput.

@gadenbuie
Copy link
Member

gadenbuie commented Dec 12, 2024

Thanks for opening this issue and for including a reprex @gsmolinski!

Smaller reprex

The same reprex as above, edited to remove intermediate reactive objects. [shinylive.io link](https://shinylive.io/r/editor/#code=NobwRAdghgtgpmAXGKAHVA6ASmANGAYwHsIAXOMpMAGwEsAjAJykYE8AKAZwAtaJWAlAB0IdJiw6M4UAqSj1qcYRBEBXWgAIAPAFoNAM2rqAJgAUoAczjsRGjas5wAQg9YBJCMdoEopIo052AVxbDRlSWhIXUj8IGzBGVQgAfVIFITwNDKwkjTkFOAzg0PDIiGjY+MSUqXD5RQzcLLAciA1a2XrCsGK2sNkyipIqpNS4AA9SRubWvImpnpC+8kmAeVVSVA34lYXeu0MTLCIAdxs+u2IjGDiANib8xXXN7Yy06iL9uw0r1Rv2e7taSdArPLakKqpdI9ZR2ZTKESORgANzgjG0en0SQGwz44KaRA2+I0jk4nDKAg0IFChJepAAJLsMUDPGiACrzdjUi5AgCO7DxG3p1TGk1h3wAyqxOBhOIo4Kh2ABmcV2N5wTgLUIAX3FNKJQvezKkrMYbK6XNCdik-MFDJF71VGilMrlcAVyqd3GkxnYMFIPgCTQAjAAGcW60L6unCqHUY0UYxorDAx7WbnfPkCiDg4WjDppp0u2XyxUqq1AuoFP0BlicCPKbUiRG8fgAQXQ7HUTSRqMYyjA2oAukA

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) {
  output$text <- renderText({
    req(input$run_text)
    Sys.sleep(3)
    "test"
  })
  
  output$tbl <- renderTable({
    req(input$run_tbl)
    Sys.sleep(3)
    head(mtcars, 10)
  })
  
  output$r_tbl <- renderReactable({
    req(input$run_reactable)
    Sys.sleep(3)
    reactable(mtcars)
  })
}

shinyApp(ui, server)

The reason that you don't see the spinner for the reactableOutput() on the first click is because htmlwidgets initially sets the entire output element to have visibility: hidden, which is only removed once the widget is successfully rendered. Hiding the entire htmlwidget element ends up hiding the progress indicator too.

@gadenbuie
Copy link
Member

gadenbuie commented Dec 12, 2024

I moved the tableOutput() example to a new issue because it has a different mechanism and can be tackled on its own.

Similarly, no busy indicators is displayed at all for visNetworkOutput.

@AkedoMakona This might be the same htmlwidgets issue as reactable. I'd be happy to look into it if you could please include a reproducible example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants