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

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

Open
nickbo90 opened this issue Jun 10, 2022 · 3 comments
Open

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

nickbo90 opened this issue Jun 10, 2022 · 3 comments
Labels

Comments

@nickbo90
Copy link

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 nickbo90 added the bug label Jun 10, 2022
@albanR
Copy link

albanR commented Aug 5, 2022

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."

@luka-TU
Copy link

luka-TU commented Jun 29, 2023

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

@marceloverdijk
Copy link

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.

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

No branches or pull requests

4 participants