From 934459498c103bf2c680bcfb58aa6a66ca7d80e6 Mon Sep 17 00:00:00 2001 From: go_gonzo Date: Mon, 9 Dec 2024 11:53:32 +0100 Subject: [PATCH 1/3] prevent early evaluation --- R/module_nested_tabs.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index e26533cc92..81af7c46c7 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -339,9 +339,9 @@ srv_teal_module.teal_module <- function(id, } if (is_arg_used(modules$server, "id")) { - do.call(modules$server, args) + do.call(modules$server, args, quote = TRUE) } else { - do.call(callModule, c(args, list(module = modules$server))) + do.call(callModule, c(args, list(module = modules$server)), quote = TRUE) } } From 7a421edc353db244030f7b0827da17b1e02e44b4 Mon Sep 17 00:00:00 2001 From: Dawid Kaledkowski Date: Thu, 9 Jan 2025 14:10:56 +0100 Subject: [PATCH 2/3] add a test --- tests/testthat/test-module_teal.R | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/testthat/test-module_teal.R b/tests/testthat/test-module_teal.R index 12d0c1c0e1..3a48c58950 100644 --- a/tests/testthat/test-module_teal.R +++ b/tests/testthat/test-module_teal.R @@ -1035,6 +1035,37 @@ testthat::describe("srv_teal teal_modules", { ) }) + testthat::it("srv_teal_module.teal_module passes quoted arguments to the teal_module$server call", { + tm_query <- function(query) { + module( + "module_1", + server = function(id, data, query) { + moduleServer(id, function(input, output, session) { + reactive(q <- eval_code(data(), query)) + }) + }, + server_args = list(query = query) + ) + } + shiny::testServer( + app = srv_teal, + args = list( + id = "test", + data = teal.data::teal_data(a_dataset = iris), + modules = modules(tm_query(quote(a_dataset <- subset(a_dataset, Species == "setosa")))) + ), + expr = { + session$setInputs(`teal_modules-active_tab` = "module_1") + session$flushReact() + + testthat::expect_setequal( + "setosa", + unique(modules_output$module_1()()[["a_dataset"]]$Species) + ) + } + ) + }) + testthat::it("srv_teal_module.teal_module passes filter_panel_api if specified", { shiny::testServer( app = srv_teal, From 174641d9b74cb0ea5eb009002588128bbc87fcd8 Mon Sep 17 00:00:00 2001 From: Dawid Kaledkowski Date: Tue, 14 Jan 2025 15:49:03 +0100 Subject: [PATCH 3/3] fix language arg for ui --- R/module_nested_tabs.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/module_nested_tabs.R b/R/module_nested_tabs.R index 88223e7a45..1b210fb7a7 100644 --- a/R/module_nested_tabs.R +++ b/R/module_nested_tabs.R @@ -108,7 +108,7 @@ ui_teal_module.teal_module <- function(id, modules, depth = 0L) { class = "teal_validated", ui_check_module_datanames(ns("validate_datanames")) ), - do.call(modules$ui, args) + do.call(what = modules$ui, args = args, quote = TRUE) ) ) @@ -341,9 +341,9 @@ srv_teal_module.teal_module <- function(id, } if (is_arg_used(modules$server, "id")) { - do.call(modules$server, args, quote = TRUE) + do.call(what = modules$server, args = args, quote = TRUE) } else { - do.call(callModule, c(args, list(module = modules$server)), quote = TRUE) + do.call(what = callModule, args = c(args, list(module = modules$server)), quote = TRUE) } }