Skip to content

Combining pickers: using Live search and Multiple together #142

@owczarz-eca

Description

@owczarz-eca

Assuming I have application like this (adjusted example from issue #7):

library("shiny")
library("shinyWidgets")


# Countries
countries <- c(
    "United Kingdom", "Germany", "United States of America", "Belgium", "China", "Spain", "Netherlands", "Mexico",
    "Italy", "Canada", "Brazil", "Denmark", "Norway", "Switzerland", "Luxembourg", "Israel", "Russian Federation",
    "Turkey", "Saudi Arabia", "United Arab Emirates"
)

ui <- fluidPage(
    tags$h2("Select countries to drill down"),
    
    dropdown(
        circle = TRUE, status = "default", icon = icon("sliders"), width = "300px",
        pickerInput(inputId = "Adverts",
                    label = "Countries",
                    choices = countries, # a list of strings
                    options = list(`actions-box` = TRUE, `live-search` = TRUE),
                    multiple = TRUE)
    ),
    verbatimTextOutput(outputId = "res")
)

server <- function(input, output, session) {

    output$res <- renderPrint({
        input$Adverts
    })
}

shinyApp(ui = ui, server = server)

I would like to combine live search and multiple selection. For example, I am interested in some countries that contain letter G (but only Germany and Belgium). Therefore, I search for G in the search box and I want to pick two countries (Germany and Belgium). Once I click on Germany the search menu expands and renders all available choices , hence disregarding the search input G. Is there a way to fix it? The same logic applies to unselecting choices, I am able to select all countries with G but when I try to unselect UK the list expands again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions