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

withSpinner prevents appendTab from working correctly #45

Closed AzlinII closed 4 years ago

AzlinII commented 4 years ago

Here is an example

library(shiny)
library(DT)
library(shinycssloaders)

ui <- 
    fluidPage(
        actionButton("new_tab", label = "New Tab"),
        tabsetPanel(id = "test",
                    tabPanel("Test1", withSpinner(DTOutput("table"))))
    )

server <- function(input, output, session) {

    data <- reactive({
        Sys.sleep(1)
        iris
    })

    output$table <- renderDT({
        datatable(data())
    })

    observeEvent(input$new_tab, {
        id <- Sys.time()
        appendTab("test", tab = tabPanel(id, id), select = TRUE)
    })

}
shinyApp(ui, server)

Click on the "New Tab" button creates a new tab but the content is the same as what's in the first tab. After clicking "New Tab" a second is when it actually creates the tabs.

Removing the withSpinner call allows for normal tab creation.

Here is my sessionInfo() ``` R version 3.6.1 (2019-07-05) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] shinycssloaders_0.3 DT_0.11 shiny_1.4.0 loaded via a namespace (and not attached): [1] Rcpp_1.0.3 rstudioapi_0.10 magrittr_1.5 xtable_1.8-4 R6_2.4.1 [6] rlang_0.4.3 fastmap_1.0.1 fansi_0.4.1 tools_3.6.1 sessioninfo_1.1.1 [11] cli_2.0.1 withr_2.1.2 htmltools_0.4.0 crosstalk_1.0.0 yaml_2.2.0 [16] digest_0.6.23 assertthat_0.2.1 crayon_1.3.4 later_1.0.0 htmlwidgets_1.5.1 [21] promises_1.1.0 glue_1.3.1 mime_0.8 compiler_3.6.1 jsonlite_1.6 [26] httpuv_1.5.2 ```
daattali commented 4 years ago

Please verify this is now fixed

AzlinII commented 4 years ago

Thanks for the quick reply! It's working now with the github version.