0
votes

I want to adjust the shiny selectizeInput widget to allow multiple choices to be selected, but the default behaviour is to keep the list of choices open until to click somewhere else (see http://shiny.rstudio.com/gallery/selectize-examples.html number 2). In my application the user must select multiple choices from time to time but most of the time just one. Hence, I want the list of shown choices to collapse after every single selection, but the shiny parameters of selectizeInput seem to not allow this functionality.

Any ideas how to alter this standard behaviour?

selectizeInput(
        inputId = "portfolios",
        label = "Select Portfolio(s):",
        choices = currPortfolios,
        selected = "",
        multiple = TRUE,
        options = list(maxItems = 5)
      )
1

1 Answers

1
votes

You can use the closeAfterSelect = TRUE option.

selectizeInput(
        inputId = "portfolios",
        label = "Select Portfolio(s):",
        choices = currPortfolios,
        selected = "",
        multiple = TRUE,
        options = list(maxItems = 5, closeAfterSelect = TRUE)
      )

Note that it's not 100% user friendly - you do have to click away from the input and then click back into any whitespace inside the input in order to re-open the list. Not a big deal, just FYI.