Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining pickers: using Live search and Multiple together #142

Closed
owczarz-eca opened this issue Jan 2, 2019 · 4 comments
Closed

Combining pickers: using Live search and Multiple together #142

owczarz-eca opened this issue Jan 2, 2019 · 4 comments

Comments

@owczarz-eca
Copy link

@owczarz-eca owczarz-eca commented Jan 2, 2019

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.

@byollin
Copy link

@byollin byollin commented Aug 27, 2019

Hey @owczarz-eca! I'm running into this exact issue as well. After searching and selecting an option, the dropdown menu is "reset" thus ignoring any text in the search box.

Did you find a resolution to this?

@trafficonese
Copy link

@trafficonese trafficonese commented Oct 25, 2019

I ran into the same problem and played a bit with the source code.
I found, that when the following line

$(el).selectpicker('refresh');
is removed, the list doesn't reload and so far I couldn't see any problems with it.

@pvictor What is the refresh for exactly? Could it be removed?

@yurasik2000
Copy link

@yurasik2000 yurasik2000 commented Nov 8, 2019

Same problem. Suggested by @trafficonese solution dosen't work for me. R 3.3.3 ShinyWidgets 0.4.9

@pvictor
Copy link
Member

@pvictor pvictor commented Nov 11, 2019

Hi,
You're right @trafficonese , this line seems unnecessary, and without it solve this issue.

So this should work now after re-installing from GitHub.

@yurasik2000 , if modifying picker JavaScript bindings, you have to run this code after to compile all bindings :

terser_file(input = bindings, output = "inst/assets/shinyWidgets-bindings.min.js")

@pvictor pvictor closed this Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.