All but one downloadHandler with shiny.fluent not working, just opens new tab running new instance of application instead of download

Viewed 193

We have a very complex app which contains 20 downloadHandler instances that serve either .csvs, .rmds, or .zip files. Until this past week they all worked, we've been doing a lot of work on other pieces, haven't tested the downloadHandlers specifically this week and at some point all of them stopped working except for one single .csv exporting one in the middle of the bunch. That one still correctly starts a download, every other one just opens a new tab in the browser with a new instance of the app, no download.

We're running this on the local machine in browser, not in the RStudio pane.

The full app is very complex so I don't have a non-working reprex for the moment, though here: https://github.com/samdupre/OSDSReprex is a reprex for an earlier very slimmed down version which has this broken functionality working throughout (bottom of each page). I've also cut out working and non-working examples of the functionality from the full app and included it below.

Because shiny.fluent does not work with downloadHandler well, we're using the recommended workaround (https://github.com/Appsilon/shiny.fluent/issues/39) where the server section of our app.R file contains downloadHandler which is triggered programmatically using shinyjs::click() based on a button present in each topic .R file. Here is the single working one and one of the non-working ones.

IN APP.R

### THIS ONE DOES NOT WORK
 observeEvent(input$page1_dd,
               click("page1_ddb"))
  
  page1_data <- imported_data %>% filter(Metric == "Population")
  
  output$page1_ddb <- downloadHandler(
    filename = function() {
      'demographic-social-data.csv' 
    },
    
    content = function(file) {
      write.csv(page1_data, file)
    }
  )

### THIS ONE WORKS
observeEvent(input$page6_dd,
               click("page6_ddb"))
  
  page6_data <- imported_data %>% filter(Metric %in% c("CrudeDeathRate","Deaths"))
  
  output$page6_ddb <- downloadHandler(
    filename = function() {
      'mortality-data.csv' 
    },
    
    content = function(file) {
      write.csv(page6_data, file)
    }
  )

and the individual page files contain:

IN TOPIC_PAGE_1.R (DOES NOT WORK)

makeCard(" ",
               div(
                 Text(i18n$t("Export demographic and social data (in .csv format)")),
                 useShinyjs(),
                 Stack(tokens = list(childrenGap = 10), horizontal = TRUE,
                       DefaultButton.shinyInput("page1_dd", text = i18n$t("Download Demographic and Social Data"), iconProps = list(iconName = "Download Demographic and Social Data")),
                       div(style = "visibility: hidden;", downloadButton("page1_ddb", label = "")))
               ),
               size = 11
      )

IN TOPIC_PAGE_6.R (WORKS)

makeCard(" ",
               div(
                 Text(i18n$t("Export mortality data (in .csv format)")),
                 useShinyjs(),
                 Stack(tokens = list(childrenGap = 10), horizontal = TRUE,
                       DefaultButton.shinyInput("page6_dd", text = i18n$t("Download Mortality Data"), iconProps = list(iconName = "Download Mortality Data")),
                       div(style = "visibility: hidden;", downloadButton("page6_ddb", label = "")))
                 ),
               size = 11
      )

Any advice on why all except one random one out of the bunch has now stopped generating a download and instead just opens a new tab instance of the app would be greatly appreciated.

Thanks in advance!

0 Answers
Related