Choices
Choices copied to clipboard
Option 'searchEnabled' set to false, but search is still enabled
Describe the bug searchEnabled is set to false. But there is still a searchbox added
To Reproduce
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/choices.js/public/assets/styles/choices.min.css" />
<script src="https://cdn.jsdelivr.net/npm/choices.js/public/assets/scripts/choices.min.js"></script>
<select name="test" id="test" multiple>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<script>
const choices = new Choices(document.getElementById('test'), {
silent: false,
searchEnabled: false,
delimiter: '|',
});
</script>
Expected behavior No search input generated ( <input type="search" name="search_terms" ...> ). I would like to generate a multi-select dropdown without a searchfield.
Desktop (please complete the following information):
- OS: Windows 11
- Browser: Chrome
- Version: 102.0.5005.115 (Officiële build) (64-bits)
Additional context Some config options are working, but the delimiter config value isn't working for example. Also would I like to disable the 'Press to select' text inside the dropdown. But I can't disable it with 'renderSelectedChoices'
Hi, If you should look into line 317 of Choices/public/assets/scripts/choices.js :
this.config.searchEnabled = this._isSelectMultipleElement || this.config.searchEnabled;
I think this line sets the search option to true whenever you are using a multiple select, even if you set it to false in your configuration. Also, it is clearly mentioned in the README file in the searchEnabled section: "Note: Multiple select boxes will always show search areas."
@albanR it would still be great to have it configurable.
Is there a good reason for this. I would also like to have a multiple select without search.
Another problem of always having a search for multiple selects is that you can enter any value:
like 42
in the second select.
The user will now expect that he/she entered a correct value (42
) which is actually not the case.
For that reason multiple select are not usable at all and I wonder how others are using multiple selects.