flexdashboard
flexdashboard copied to clipboard
Bug in `downloadButton` with `downloadHandler` explicitly assigned to output slot
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 anoutput
slot, 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
I suspect this is related to the issue reported in #141.
what is the status here? I still have this error with latest flexdashboard