A minimal reprex is below. Note how, after the update happens, Option 3
is selected, instead of Option 1
.
Seems this isn't an issue when multiple = TRUE
library(shiny)
ui <- bslib::page_fluid(
selectizeInput("foo", "Foo", choices = c("Option 1", "Option 2", "Option 3"))
)
server <- function(input, output, session) {
observe({
updateSelectizeInput(
inputId = "foo",
options = list(placeholder = "Select an option")
)
})
}
shinyApp(ui, server)
A workaround is to include the currently selected value on update:
updateSelectizeInput(
inputId = "foo",
selected = isolate(input$foo),
options = list(placeholder = "Select an option")
)