insightsengineering / insightsengineering/teal.widgets

[Feature Request]: `table_with_settings_srv` accepts NULL

Open
#344 0 comments 1 reaction 0 assignees View on GitHub
core enhancement good first issue TrackB_RMedicine_Hackathon_Apr2026
Dominant language
R
Stars
6
Forks
8
PR merge metrics
No merged PRs in 30d

Description

### Feature description

In `tm_a_mmrm` the logic passes `NULL` to table_with_settings_srv and `plot_with_settings_srv`, which fails on the latter and shows an error in the console.

Suggestion is to handle it correctly and (possibly) show a placeholder text showing "no table/image provided"

This should never appear in a module, but I think it's fair for the functions to accept it

### Example app (with NULL added)

```r
pkgload::load_all("../teal.widgets")
ui <- bslib::page_fluid(
table_with_settings_ui(id = "null_table"),
table_with_settings_ui(id = "rtables_table"),
table_with_settings_ui(id = "gtsummary_table"),
table_with_settings_ui(id = "gt_table")
)

server <- function(input, output, session) {
table_r_rtables <- reactive({
l <- basic_table() %>%
split_cols_by("ARM") %>%
analyze(c("SEX", "AGE"))
build_table(l, DM)
})

table_r_gtsummary <- reactive({
gtsummary::tbl_summary(mtcars)
})

table_r_gt <- reactive({
mtcars %>%
gt::gt() %>%
gt::tab_header(title = "Motor Trend Car Road Tests")
})

table_with_settings_srv(id = "null_table", table_r = reactive(NULL))
table_with_settings_srv(id = "rtables_table", table_r = table_r_rtables)
table_with_settings_srv(id = "gtsummary_table", table_r = table_r_gtsummary)
table_with_settings_srv(id = "gt_table", table_r = table_r_gt)
}

shinyApp(ui, server) |> shiny::runApp()
#> ℹ Loading teal.widgets
#>
#> Listening on http://127.0.0.1:7380
#> Warning: Error in render_table_to_html.default: Unsupported table type. table_with_settings supports rtables (ElementaryTable, TableTree), gtsummary, or gt (gt_tbl) objects.
#> 119: stop
#> 118: render_table_to_html.default [/path/to/teal.widgets/R/table_with_settings.R#32]
#> 116: renderUI [/path/to/teal.widgets/R/table_with_settings.R#274]
#> 115: func
#> 99: output$null_table-table_out_main
#> 1: shiny::runApp
```

Metadata

### 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

Research direction

The failure points to R/table_with_settings.R, especially render_table_to_html.default and table_with_settings_srv; start by tracing how a NULL table reaches rendering. Run the example app with reactive(NULL) and verify that both table and image cases are accepted without a console error, with the requested placeholder behavior if implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.