I am working in a R Shiny Flexdashboard, and including a download button. To distribute the items on the screen I would like to use splitLayout. But the issue is, if I use downloadButton inside the SplitLayout, the downloadHandler throws a very strange behaviour... in RStudio, it tries to save an (apparently) empty .Rmd file. In the browser, it tries to save an (apparently) empty .htm file...
The code with a minimal example is the following:
splitLayout(cellWidths = c("30%", "70%"),
wellPanel(
downloadButton("downloadData")
),
dataTableOutput("OrigData")
)
output$downloadData<-downloadHandler(
filename = "OriginalData.csv" ,
content = function(file) {
write.csv(mtcars, file=file)
},
contentType="text/csv"
)
output$OrigData<-DT::renderDataTable(mtcars)
I would like to understand what is going on...
From the link apparently downloadHandler works just if one put it just after the download button code (also just if the last one wrapped inside a wellPanel)... But the code works well if isolated just this part.
Other parts of app are still just text/Markdown, and column and tab headers because it is in the draft state...
What is happening when the downloadHandler tries to save a .Rmd and/or html file?
I am including an answer because I tried to answer the comments and it disappeared...I believe I figured out the answer but it would be an intriguing flexdashboard+downloadHandler behaviour...
The problem appears to be the titles (column, tabs titles - .data-navmenu, .storyboard)... It makes little sense, are them just titles… But I modified the original titles (there were some similar titles) and it also solved the issue… the app stopped trying to save .Rmd or .htm, and started to enable to download .csv…
I believe the downloadHandler() does not work when there are similar column/tab titles in the flexdashboard... Does it make sense? It sounds a bit strange to be the answer for this but worked...