tamarack
tamarack

Reputation: 437

selectizeInput() in R Shiny doesn't allow typing until I have selected and deleted an entry

I have a selectizeInput() box in my ui, with server-side selectize updateSelectizeInput() in my server function. I want the user to be able to type suggestions into the input box, but it won't let me enter anything until I have selected and then deleted an entry. In the full version of my app, there are several thousand options, so server-side updating is necessary, and scrolling through the options is impractical. I isolated that part of my app, entered below.

ui <- fluidPage(
  selectizeInput(inputId = 'cwdsearchscanid', label = 'ScanID Lookup',
                 choices = NULL,
                 selected = NULL,
                 options = list(placeholder = 'Enter ScanID')
  )
)

server <- function(input, output, session) {
  updateSelectizeInput(session, 'cwdsearchscanid', choices = c('', '1234', '2345', '3456', '4567', '5678', '6789', '7890', '8901', '9012', '0123'), server = T)
}

shinyApp(ui = ui, server = server)

Upvotes: 2

Views: 2774

Answers (1)

YBS
YBS

Reputation: 21297

you should use selected = character(0) as shown below

updateSelectizeInput(session, 'cwdsearchscanid',
                     choices = c('', '1234', '2345', '3456', '4567', '5678', '6789', '7890', '8901', '9012', '0123'),
                     selected = character(0),
                     server = TRUE)
  

Upvotes: 5

Related Questions