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

Precedence of minimumResultsForSearch vs. minimumInputLength #6240

Open
relikd opened this issue Mar 30, 2023 · 2 comments
Open

Precedence of minimumResultsForSearch vs. minimumInputLength #6240

relikd opened this issue Mar 30, 2023 · 2 comments

Comments

@relikd
Copy link

relikd commented Mar 30, 2023

This is a bug in my opinion but would qualify as a feature request.

Given the example below, with a dataset of 4 entries, I would expect that select2 will show the entire list instead of a message prompt to enter at least 1 character. After all, the search bar should be hidden before it checks for user input.

$('select').select2({
  minimumResultsForSearch: 20,
  minimumInputLength: 1,
});
@kevin-brown
Copy link
Member

Yup, this is a feature request. Here's a quick explanation of why we can't universally do this.

minimumInputLength tells Select2 to not kick off a query for results unless X number of characters are present in the search box. minimumResultsForSearch tells Select2 to show or hide the search box based on the number of results that come back in a query. Because minimumInputLength does not kick off a query unless there are characters present, minimumResultsForSearch does not know how many results are present and therefore it cannot determine if the search box needs to be displayed.

I'm pretty sure the only time when we could allow them to be combined is when we can run a blank search to get the first page of results, which basically means only standard <select> use cases (maybe with array loading as well), definitely not with AJAX and definitely not with custom result handlers. If you're able to work through that challenge, I'll definitely entertain a pull request for handling this edge case.

@relikd
Copy link
Author

relikd commented Apr 1, 2023

Ahh, I see the problem. Yes, in my case it would indeed be a local search on select options. Unfortunatelly I dont have the time to look into this. As a workaround I just disable the minLength requirement ^.^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants