Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent too early evaluation #1425

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

@averissimo averissimo Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test before merging, such as:

testthat::it("srv_teal_module.teal_module accepts quoted arguments", {
  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)
      )
    }
  )
})

} else {
do.call(callModule, c(args, list(module = modules$server)))
do.call(callModule, c(args, list(module = modules$server)), quote = TRUE)
}
}

Expand Down
Loading