diff --git a/R/dropdown.R b/R/dropdown.R index d04e23ea..4bb88156 100644 --- a/R/dropdown.R +++ b/R/dropdown.R @@ -149,7 +149,8 @@ selectInput <- function(inputId, label, choices, selected = NULL, multiple = FAL #' @param input_id The id of the input object #' @param choices All available options one can select from. If no need to update then leave as \code{NULL} #' @param choices_value What reactive value should be used for corresponding choice. -#' @param value The initially selected value. +#' @param value A value to update dropdown to. \code{character(0)} and \code{""} clear the dropdown. +#' \code{NULL} (the default) does not change selection. #' #' @examples #' if (interactive()) { diff --git a/inst/www/shiny-semantic-dropdown.js b/inst/www/shiny-semantic-dropdown.js index b32988aa..6ea29780 100644 --- a/inst/www/shiny-semantic-dropdown.js +++ b/inst/www/shiny-semantic-dropdown.js @@ -32,6 +32,10 @@ $.extend(semanticDropdownBinding, { // Given the DOM element for the input, set the value. setValue: function(el, value) { + if (value === '') { + $(el).dropdown('clear'); + return; + } if ($(el).hasClass('multiple')) { $(el).dropdown('clear', true); value.split(",").map(v => $(el).dropdown('set selected', v)); diff --git a/man/update_dropdown_input.Rd b/man/update_dropdown_input.Rd index 17ed4c83..4bf5fee4 100644 --- a/man/update_dropdown_input.Rd +++ b/man/update_dropdown_input.Rd @@ -21,7 +21,8 @@ update_dropdown_input( \item{choices_value}{What reactive value should be used for corresponding choice.} -\item{value}{The initially selected value.} +\item{value}{A value to update dropdown to. \code{character(0)} and \code{""} clear the dropdown. +\code{NULL} (the default) does not change selection.} } \description{ Change the value of a \code{\link{dropdown_input}} input on the client.