Strange browser behavior with downloadButton

Hi,
I am working in shinydashboard with a downloadButton and an DownloadHandler function to process a Rnw file and download a PDF. When I click on the downloadButton, Chrome opens up a blank window while the program is processing the Rnw file. I can click back on the main Dashboard window and see that hings are running.
This strange behavior appears to happen when the downloadButton is clicked.

Why is Chrome opening up a new window? (also, this is a new development. If only occurred once I completed developing the Rnw file.)

My code:
downloadButton (in the sidebar of the dashboard):

                             #Action Button
                               actionButton("profile","View Profile"),
                               #   actionButton("comparison","View Comparison"),  Disabled in V1
                               actionButton("contact","Contact SDO",onclick ="window.open('https://goo.gl/forms/xvyxzq6DGD46rMo42', '_blank')") ,
                               downloadButton("outputPDF", label="Download PDF Report",
                               style="color: black; background-color: gray90; border-color: black")

The downloafHandler function:

#Event to output PDF documents

output$outputPDF <- downloadHandler(
    filename <- function() {
         paste0(input$unit," Community Profile Report ",as.character(Sys.Date()),".pdf")
      },
    content <- function(file) {
      withProgress(message = 'Generating Report', value = 0, {  # Initialize Progress bar

      tempPDF <-  "SDO_Report.pdf"
      tempTex <- "SDO_Report.tex"
      tempReport <- "SDO_Report.Rnw"
      

      incProgress()
      
      # Set up parameters to pass to Rnw document
      outChk <- input$outChk
      olistID <- idList
      olevel <- input$level
      ocurACS <- curACS
      ocurYr <- curYr
      placelist <- PlaceList
      incProgress()
  
      #knitting file and copy to final document
     knit(tempReport)
     tools::texi2pdf(tempTex)
      
      file.rename(tempPDF, file) # move pdf to file for downloading
      incProgress()
      }) # Progress Bar 
    } #Content
) #Download Handler

Thanks in Advance,
AB

One additional issue:
Chrome opens up a window with this address:
http://127.0.0.1:3644/session/8838345386b24351980112c0746e0b8e/download/outputPDF?w=

(the "/download/outputPDF?w=' portion is repeated each time. Locally, this has been accompanied with the following message:
This site can’t be reached
The webpage at http://127.0.0.1:3644/session/361fcc2368bba76913a5048f423e86e3/download/outputPDF?w= might be temporarily down or it may have moved permanently to a new web address.
ERR_INVALID_RESPONSE

Again, this behavior is new.
Any ideas?
TIA

Hi @adambickford,

usually the message "This site can't be reached" is shown when something went wrong while preparing the output.
I think the best option is to debug your downloadHandler content part to show if there anything goes wrong.

Best regards
Sebastian

PS: I didn't see the use of withProgress() in a downloadHandler yet, are you sure this is working properly?

Hi SebastianVock,

The withProgress() displays the progress bar. I read here: https://github.com/rstudio/shiny/issues/1660 that this can be placed in the content function without an issue.

I'll disable this and see what happens.
Cheers--
AB

1 Like

That's really nice. Thank's for this hint.

Chrome is opening up a new window because the onclick parameter in the actionButton explicitly tells it to. Remove the '_blank' parameter and it will open in the same window.

Thanks Jason,
However, the issue is not with the actionButton (which is working as intended) but with the downloadButton. I think what is happening is that Chrome is displaying a blank window during the processing time. I'll need to revise the Rnw file so that it runs faster.
Cheers--
AB