How to deselect selected input

This program allows fort he selection of many files from a folder. Is there any way to deselect the selected files? For example, I select some file I do not really want to select and I need to undo the selection.

library(shiny)
library(reprex)


ui <- fluidPage(
   sidebarLayout(
     sidebarPanel(
        tags$style(type='text/css',
                   ".selectize-dropdown-content{
                 height: 1000px;
                 width: 800px;
                 background-color: #b0c4de;
                 font-size: 12px; line-height: 12px;
                }"),
       setwd("~/Development/Dir/OUT/openMS/INPUT_DATA/"),    
       
       selectInput('selectfile','Select File', choice = list.files(),multiple = TRUE),      

       textOutput('fileselected'),
       setwd("~/Development/Dir") 
       ),
     mainPanel(

    )
   )
)

server <- function(input, output){
  
  output$fileselected <- renderText({
    paste0('You have selected: ', input$selectfile)
  })

}

shinyApp(ui = ui, server = server)

Hi, just to check: do you mean giving the user less choices to choose from or letting the user undo the selection? If you mean the later, they can do this by clicking something they've already selected again.

You can try it out yourself here ^^
http://shiny.rstudio.com/gallery/selectize-vs-select.html

1 Like

Check

1 Like

Hi sowla,

Yes. it works for single selection, but I cannot get it to work for multiple selections? Is there any thing else I should include in the selectInput statement?

Thanks

Hi I'm sorry, I'm not entirely sure I understand. Did you try the example(s) in the link? If you haven't, could try this first? :slight_smile:

In my experience, for the "No choose prompt, multiple" Select example, I can select many options and deselect them all one by one. Similarly, in the Selectize example, I can select many options and deselect by clicking the option(s) again and pressing delete. This time though, if I also press Alt or Shift at the same time, I can select multiple options before pressing delete. I use a mac, so the keys might be different if you use something else.

Thank you!. I tried the examples, but I did not use any keys. I will try again.

It does work in my PC selecting the item and pressing Delete. Thank you!

Thanks very much for your info.

This is a repeat of the previous thank you note that I cannot delete.

I am having the same problem. It's a pity that you have to press Delete to remove options. That is not obvious. A click should be enough to do it.

1 Like