rstudio / rstudio/flexdashboard
Bug in `downloadButton` with `downloadHandler` explicitly assigned to output slot
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 848
- Forks
- 298
- PR merge metrics
- No merged PRs in 30d
Description
This report is for two separate, but related issues.
In flexdashboard the downloadButton() doesn't seem to behave as documented. There are two issues that I could identify:
- When used as per the documentation (
?downloadButton), with thedownloadHandler()explicitly assigned to anoutputslot, the download button doesn't render at all. - When defining the
downloadHandler()anonymously, the download button will render, but it's label will be hardcoded toDownload, as it seems to ignore custom labels.
None of these issues seem to affect the Download Link, which both renders as expected and takes into account a custom label.
Here's a minimum reproducible example.
---
title: "Bug with download button"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
Column {.sidebar}
---
```{r}
data("mtcars")
## download link works as documented
tags$div("Link displayed as expected:")
downloadLink(outputId = "dwnLink", label = "Download Link")
output$dwnLink <- downloadHandler(
filename = function() {"mtcars.csv"},
content = function(file){
write.csv(mtcars, file)
}
)
tags$hr()
## does NOT work as documented:
## download button doesn't render at all
tags$div("Button NOT displayed:")
downloadButton(outputId = "dwnButton", label = "Download Button")
output$dwnButton <- downloadHandler(
filename = function() {"mtcars.csv"},
content = function(file) {
write.csv(mtcars, file)
}
)
tags$hr()
## undocumented behavior
## downloadHandler() used anonymously, i.e. NOT explicitly assigned to an output slot
## button renders, BUT button label doesn't change
tags$div("Button displayed, but custom label ignored:")
downloadButton(outputId = "dwnButton2", label = "Download Button (LABEL IGNORED)")
downloadHandler(
filename = function() {"mtcars.csv"},
content = function(file) {
write.csv(mtcars, file)
}
)
tags$hr()
```
And the corresponding screenshot:

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS
Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_0.12.18 digest_0.6.15 rprojroot_1.3-2 mime_0.5
[5] R6_2.2.2 xtable_1.8-2 jsonlite_1.5 backports_1.1.2
[9] magrittr_1.5 evaluate_0.10.1 stringi_1.1.6 DT_0.4
[13] rmarkdown_1.10 flexdashboard_0.5.1.1 tools_3.4.4 stringr_1.2.0
[17] htmlwidgets_1.0 shiny_1.0.5 httpuv_1.3.5 yaml_2.1.16
[21] compiler_3.4.4 htmltools_0.3.6 knitr_1.19
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided minimum reproducible example and the ?downloadButton documentation, then compare downloadButton/downloadHandler behavior with the working downloadLink case. Confirm the two reported outcomes: an explicitly assigned handler should render its button, and an anonymous handler should preserve the custom label.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100