Why does my download button activate twice in shiny app?

So I have a shiny app (https://github.com/tadeu95/BAGs) (http://tadeu-apps.shinyapps.io/bags) and I have several download buttons. Recently what has started to happen is that when I click the download button it activates two times and downloads the same file twice. I've tried on chrome, edge and mozzila and happens every time. I don't know what happened because I didn't touch the part of the code where the downloads are implemented.
This is a short reproducible example:


  taxon9<-bold_seqspec(taxon=groups, format = "tsv")

ui <- fluidPage(textInputAddon(inputId="taxa2",addon=icon("search"),width="500px",label=tags$h5(tags$strong("Enter the name of the taxonomic group or groups separated by commas, without spaces:")),placeholder="Example: Carnivora,Ursidae,Artiodactyla,Soricomorpha"),downloadBttn("downloadData_2",size="sm","Download"))

server <- function(input, output) {
  taxaInput_2 <- reactive({grades2(unlist(strsplit(input$taxa2, ",")))})
  output$downloadData_2 <- downloadHandler(
    filename = function() {
      paste(input$taxa2,sep_out=",", ".tsv")
    content = function(file) {
        message=paste0("Downloading and annotating library for ",input$taxa2,sep_out=","), detail='This may take several minutes',
          write_tsv(taxaInput_2(), file)


One thing I've just discovered is that if instead of clicking the download button with the left button of the mouse, I click the right button and choose "open link in a new tab", it downloads the file correctly only once.

If anyone has any idea what the reason might be, I will be very thankful.

1 Like

Hi, I' m just commenting to say that I have the exact same issue, on my shiny app running on Windows10, R 4.0. It started hapenning without change any change in the code either.
So I'd be very thankful too if anyone had an idea.

If you want to get to the bottom of this, the place to start would be to generate a minimal reprex (https://mastering-shiny.org/action-workflow.html#getting-help) that any one can run to recreate the problem.

Thank you for your answer.
You're right I should have done that, here is the reprex :


ui <- fluidPage(
    titlePanel("Download reprex"),

                outputId = "download",
                label = "Download data as .RData",
                style = "bordered",
                color = "default")
                outputId = "download",
            label = "Download data as .RData")


# Define server logic required to draw a histogram
server <- function(input, output) {
    data <- data.frame(x1 = runif(100), r2 = runif(100))
    output$download <- shiny::downloadHandler(
        filename = function() {
        content = function(file) {
            save(data, file = file)

# Run the application 
shinyApp(ui = ui, server = server)

It actually points out that the issue seems specific to shinyWidgets, as the shiny function triggers a normal behavior (one event only), whereas two are triggered with the shinyWidgets function.

Here is the sessionInfo() :

R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    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] shinyWidgets_0.5.2 shiny_1.4.0.2     

loaded via a namespace (and not attached):
 [1] Biobase_2.48.0              edgeR_3.30.0                bit64_0.9-7                 jsonlite_1.6.1              splines_4.0.0               shinybusy_0.2.0            
 [7] assertthat_0.2.1            stats4_4.0.0                blob_1.2.1                  GenomeInfoDbData_1.2.3      yaml_2.2.1                  pillar_1.4.4               
[13] RSQLite_2.2.0               lattice_0.20-41             glue_1.4.1                  limma_3.44.1                digest_0.6.25               GenomicRanges_1.40.0       
[19] RColorBrewer_1.1-2          promises_1.1.0              XVector_0.28.0              colorspace_1.4-1            htmltools_0.4.0             httpuv_1.5.2               
[25] Matrix_1.2-18               pkgconfig_2.0.3             DESeq2_1.28.1               baySeq_2.22.0               XML_3.99-0.3                genefilter_1.70.0          
[31] zlibbioc_1.34.0             purrr_0.3.4                 xtable_1.8-4                scales_1.1.1                later_1.0.0                 BiocParallel_1.22.0        
[37] tibble_3.0.1                annotate_1.66.0             IRanges_2.22.2              ggplot2_3.3.0               ellipsis_0.3.1              SummarizedExperiment_1.18.1
[43] BiocGenerics_0.34.0         crayon_1.3.4                survival_3.1-12             magrittr_1.5                mime_0.9                    TCC_1.28.0                 
[49] memoise_1.1.0               evaluate_0.14               ROC_1.64.0                  shinydashboard_0.7.1        tools_4.0.0                 lifecycle_0.2.0            
[55] matrixStats_0.56.0          S4Vectors_0.26.1            munsell_0.5.0               locfit_1.5-9.4              DelayedArray_0.14.0         AnnotationDbi_1.50.0       
[61] compiler_4.0.0              DESeq_1.39.0                GenomeInfoDb_1.24.0         rlang_0.4.6                 grid_4.0.0                  RCurl_1.98-1.2             
[67] shinydashboardPlus_0.7.0    rstudioapi_0.11             htmlwidgets_1.5.1           bitops_1.0-6                rmarkdown_2.1               gtable_0.3.0               
[73] abind_1.4-5                 DBI_1.1.0                   R6_2.4.1                    dplyr_0.8.5                 knitr_1.28                  fastmap_1.0.1              
[79] bit_1.1-15.2                parallel_4.0.0              Rcpp_1.0.4.6                vctrs_0.3.0                 geneplotter_1.66.0          tidyselect_1.1.0           
[85] xfun_0.14      

I am using Rstudio v1.3.959. When the app is launched in my browser, the problem persists.

Hope it helps.

I think you should file an issue with the maintainer of shinyWidgets

1 Like

Created issue : https://github.com/dreamRs/shinyWidgets/issues/285.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.