diff --git a/R/blocks.R b/R/blocks.R index 5199559e..e7791de7 100644 --- a/R/blocks.R +++ b/R/blocks.R @@ -327,7 +327,10 @@ new_summarize_block <- function(func = character(), select_names <- function(funcs) funcs select_choices <- function(funcs) { - replicate(length(funcs), function(data) list(choices = colnames(data))) + replicate( + length(funcs), + set_fun_env(function(data) list(choices = colnames(data))) + ) } summarize_expr <- function(data, funcs, columns) { @@ -349,7 +352,7 @@ new_summarize_block <- function(func = character(), } } - if (!all(lengths(columns))) { + if (!length(columns) || any(!lengths(columns))) { return(quote(identity())) } diff --git a/R/fields.R b/R/fields.R index 76eb0059..64a3564d 100644 --- a/R/fields.R +++ b/R/fields.R @@ -494,7 +494,7 @@ update_field_components.list_field <- function(x, env = list()) { #' @export update_field_value.list_field <- function(x, new) { - if (!length(new)) { + if (!length(new) || any(!lengths(new))) { return(x) } diff --git a/R/utils.R b/R/utils.R index 5a65c4e4..94d79dc3 100644 --- a/R/utils.R +++ b/R/utils.R @@ -402,3 +402,11 @@ get_block_title <- function(x) { module_server_test <- function(id, x, in_dat, is_prev_valid, ...) { generate_server(x = x, in_dat = in_dat, id = id, is_prev_valid = is_prev_valid) } + +pkg_name <- function() utils::packageName() + +pkg_env <- function() asNamespace(pkg_name()) + +set_fun_env <- function(fun, env = pkg_env()) { + `environment<-`(fun, env) +}