Skip to content

Commit

Permalink
bugfix: updateSelectInput handle correctly named list as choices
Browse files Browse the repository at this point in the history
Correct a bug where value is not correctly attributed to the data-value attribute in semantic selectInput when using named list as choices.
  • Loading branch information
DangerousWizardry committed Apr 12, 2024
1 parent a0eb214 commit 3e557c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/dropdown.R
Expand Up @@ -247,9 +247,11 @@ updateSelectInput <- function(session, inputId, label = NULL, choices = NULL, se
if (!is.null(selected)) selected <- paste(as.character(selected), collapse = ",") else selected <- NULL
if (!is.null(choices)) {
choices_text <- names(choices)
choices_value <- unlist(unname(choices))
if (identical(choices_text, NULL))
choices_text <- choices
options <- jsonlite::toJSON(list(values = data.frame(name = choices_text, text = choices_text, value = choices)))

options <- jsonlite::toJSON(list(values = data.frame(name = choices_text, text = choices_text, value = choices_value)))
} else {
options <- NULL
}
Expand Down

0 comments on commit 3e557c7

Please sign in to comment.