[Bug]: App is "frozen" when `reactive()` data is not passed
What happened?
When passing data as (unevaluated) eventReactive to srv_teal directly then the teal-app looks like frozen. Propose a better solution for this.
app code
options(
teal.log_level = "TRACE",
teal.show_js_log = TRUE,
# teal.bs_theme = bslib::bs_theme(version = 5),
shiny.bookmarkStore = "server"
)
library(scda)
pkgload::load_all("teal")
# pkgload::load_all("teal.slice")
ui_data <- function(id) {
ns <- NS(id)
tagList(
actionButton(ns("submit"), label = "Submit to run")
)
}
srv_data <- function(id, ...) {
moduleServer(id, function(input, output, session) {
eventReactive(input$submit, {
data <- teal_data() |>
within({
logger::log_trace("Loading data")
ADSL <- scda::synthetic_cdisc_data("latest")$adsl
ADTTE <- scda::synthetic_cdisc_data("latest")$adtte
iris <- iris
})
join_keys(data) <- default_cdisc_join_keys[c("ADSL", "ADTTE")]
data
})
})
}
modules <- modules(
teal.modules.general::tm_data_table("Data Table"),
example_module("Example Module", datanames = "ADTTE"),
module(
ui = function(id) {
ns <- NS(id)
tagList(
tableOutput(ns("filter_summary"))
)
},
server = function(id, datasets) {
moduleServer(id, function(input, output, session) {
output$filter_summary <- renderTable({
datasets$get_filter_overview(datanames = datasets$datanames())
})
})
}
)
)
shinyApp(
ui = function(request) {
fluidPage(
ui_data("data"),
ui_teal(id = "teal", modules = modules)
)
},
server = function(input, output, session) {
data_rv <- srv_data("data", data = data, modules = modules)
srv_teal(id = "teal", data = data_rv, modules = modules)
}
)
It's not that bad, you can see a huge button with Submit to run. So even though you can click between modules, it looks like broken, but there is another button that triggers the data pull. Also when data is fetched the Computing... progress is visible.
We could disable the ability to go through modules, and grey them out, leaving only the Submit to run being the only active button. Or we can display a message in the module saying that data is empty?
@m7pr in the range of all the issue we solved "it is not bad", but inconsistent with teal_data_module which disables and greys-out tabs on init and enable them when initial data is provided.
Related to https://github.com/insightsengineering/teal/issues/1308
Acceptance Criteria
- tabs are disabled and hidden with message when reactive
teal_datais not executed