Choices icon indicating copy to clipboard operation
Choices copied to clipboard

Option 'searchEnabled' set to false, but search is still enabled

Open nickbo90 opened this issue 2 years ago • 3 comments

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'

nickbo90 avatar Jun 10 '22 15:06 nickbo90

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 avatar Aug 05 '22 10:08 albanR

@albanR it would still be great to have it configurable.

luka-TU avatar Jun 29 '23 08:06 luka-TU

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:

image

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.

marceloverdijk avatar Jul 21 '23 13:07 marceloverdijk