insightsengineering / insightsengineering/teal.modules.general

[Bug]: ggplot2_args not behaving properly with teal_data_module

Open
#974 1 comment 1 reaction 1 assignee Claimed by @stefanlinner View on GitHub
bug core good first issue TrackB_RMedicine_Hackathon_Apr2026
Dominant language
R
Stars
16
Forks
23
PR merge metrics
No merged PRs in 30d

Description

### What happened?

A bug happened!

`ggplot2_args` throws an error when teal app using using teal_data_module().

Code

```r
library(teal)

tdm <- teal_data_module(
ui = function(id) {
ns <- NS(id)
actionButton(ns("submit"), label = "Load data")
},
server = function(id) {
moduleServer(id, function(input, output, session) {
eventReactive(input$submit, {
data <- within(
teal_data(),
{
iris <- iris
mtcars <- mtcars
}
)
data
})
})
}
)

app <- init(
data = tdm,
modules = modules(
tm_g_distribution(
dist_var = data_extract_spec(
dataname = "iris",
select = select_spec(variable_choices("iris"), "Petal.Length")
),
ggplot2_args = teal.widgets::ggplot2_args(
theme = list(text = element_text(size = 20))
)
)
),
title = "my teal app"
)

shinyApp(app$ui, app$server)
```

Image

This is because R immediately runs `element_text(size = 20)`.

One way to fix it from user's perspective is to `quote()` it.

```r
ggplot2_args = teal.widgets::ggplot2_args(
theme = list(text = quote(element_text(size = 20)))
)
```

Is this the only way to do this or is there a better way?

### sessionInfo()

```R
r$> sessionInfo()
R version 4.5.2 (2025-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.7.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggpp_0.5.8-1 magrittr_2.0.4 tibble_3.3.0 tidyr_1.3.1 dplyr_1.1.4
[6] teal.modules.general_0.6.0 teal.transform_0.7.1.9001 ggplot2_4.0.0 teal_1.1.0.9017 teal.slice_0.7.1.9004
[11] teal.data_0.8.0.9002 teal.code_0.7.1.9000 shiny_1.12.1

loaded via a namespace (and not attached):
[1] shinyvalidate_0.1.3 gtable_0.3.6 xfun_0.52 bslib_0.9.0 shinyjs_2.1.0 htmlwidgets_1.6.4
[7] teal.widgets_0.5.1.9005 formatters_0.5.12 vctrs_0.6.5 tools_4.5.2 crosstalk_1.2.1 generics_0.1.4
[13] pkgconfig_2.0.3 mirai_2.5.0 checkmate_2.3.2 RColorBrewer_1.1-3 S7_0.2.1 lifecycle_1.0.4
[19] compiler_4.5.2 farver_2.1.2 textshaping_1.0.1 fontawesome_0.5.3 httpuv_1.6.16 shinyWidgets_0.9.0
[25] htmltools_0.5.9 sass_0.4.10 yaml_2.3.10 later_1.4.4 pillar_1.11.1 crayon_1.5.3
[31] jquerylib_0.1.4 MASS_7.3-65 DT_0.33 cachem_1.1.0 rtables_0.6.15 mime_0.13
[37] tidyselect_1.2.1 digest_0.6.39 stringi_1.8.7 purrr_1.0.4 labeling_0.4.3 fastmap_1.2.0
[43] grid_4.5.2 cli_3.6.5 logger_0.4.1 bsicons_0.1.2 withr_3.0.2 teal.reporter_0.6.0.9002
[49] scales_1.4.0 promises_1.5.0 backports_1.5.0 otel_0.2.0 gridExtra_2.3 ragg_1.4.0
[55] memoise_2.0.1 evaluate_1.0.5 knitr_1.50 shinycssloaders_1.1.0 rlang_1.1.6 nanonext_1.7.0
[61] Rcpp_1.1.0 polynom_1.4-1 xtable_1.8-4 glue_1.8.0 renv_1.1.4 formatR_1.14
[67] jsonlite_2.0.0 teal.logger_0.4.1.9002 R6_2.6.1 systemfonts_1.2.3 fs_1.6.6
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct.

### Contribution Guidelines

- [x] I agree to follow this project's Contribution Guidelines.

### Security Policy

- [x] I agree to follow this project's Security Policy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.