Companion to viz_select_input(), wrapping
shinyWidgets::updateVirtualSelect() so the empty-string "no selection"
choice is relabelled consistently with the UI side.
Arguments
- session
The
sessionobject passed to the module server function.- inputId
The id of the input to update.
- choices
New choices for the input, or
NULLto leave them unchanged.- selected
New value(s) to select. When
NULLandchoicesis given, the current value is kept if it is still valid, falling back to the first choice. WhenNULLandchoicesis not given, the selection is left unchanged.- ...
Further arguments passed to
shinyWidgets::updateVirtualSelect().
Details
Unlike shinyWidgets::updateVirtualSelect(), supplying choices without a
selected does not clear the widget: the current value is kept when it is
still one of the new choices, and the first choice is selected otherwise.
This mirrors shiny::updateSelectInput(), which never leaves a single select
with no value.
Examples
library(shiny)
library(VizModules)
server <- function(input, output, session) {
observeEvent(input$reset, {
update_viz_select(session, "gene", choices = c("", "GENE1", "GENE2"))
})
}