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

WIP variable_choices with choices as delayed_data #268

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 9 additions & 7 deletions R/optionalInput.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,14 @@ optionalSelectInput <- function(inputId, # nolint
checkmate::check_class(label, "html")
)
stopifnot(is.null(choices) || length(choices) >= 1)
stopifnot(
is.null(selected) ||
length(selected) == 0 ||
all(selected %in% choices) ||
all(selected %in% unlist(choices, recursive = FALSE))
)
if (!inherits(choices, "function")) {
stopifnot(
is.null(selected) ||
length(selected) == 0 ||
all(selected %in% choices) ||
all(selected %in% unlist(choices, recursive = FALSE))
)
}
checkmate::assert_flag(multiple)
checkmate::assert_string(sep, null.ok = TRUE)
checkmate::assert_list(options)
Expand Down Expand Up @@ -212,7 +214,7 @@ optionalSelectInput <- function(inputId, # nolint
shinyWidgets::pickerInput(
inputId = inputId,
label = label,
choices = raw_choices,
choices = if (inherits(raw_choices, "function")) raw_choices() else raw_choices,
Copy link
Contributor

@gogonzo gogonzo Oct 2, 2024

Choose a reason for hiding this comment

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

isn't raw_choices a function of data? I think so, which means that this change introduces a bug, as evaluation raw_choices() will throw an error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this whole PR was wrong, I will write what was the fix on the original issue insightsengineering/teal.goshawk#301

selected = raw_selected,
multiple = TRUE,
width = width,
Expand Down
Loading