I have a shiny app containing a server-side selectize input with a long list (>10k) of choices. I would like to update the selection upon clicking a button. Here is a reproducible example
library(shiny)
ui <- fluidPage(
actionButton('buttonid','Button'),
selectizeInput("listid", "A long list", choices = NULL)
)
server <- function(input, output, session)
{
updateSelectizeInput(session, "listid", choices = paste("Item", 1:10000), server = T)
observeEvent(input$buttonid,
{
updateSelectizeInput(session, "listid", selected = "Item 1234")
})
}
shinyApp(ui = ui, server = server)
The above code results in a blank selection when I press the button. However, if I search for "Item 1234", then change selection, and press the button, now the item gets selected.
Also, trying to select an item between Item 1 and 1000 does not give problems, presumably because 1000 items get loaded at the beginning.
This seems akin to this old bug, but I am not sure if there is a workaround https://github.com/rstudio/shiny/issues/1018