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

In multiselect "No choices to choose from" is sometimes displayed even if there are choices #1212

Open
DJTommek opened this issue Sep 26, 2024 · 0 comments
Labels

Comments

@DJTommek
Copy link

Describe the bug

If you select all possible choices, dropdown will show "No choices to choose from", which is correct. But if you remove at least one value, text is still visible, even if there value to choose from.

This is visible also in official demo on https://choices-js.github.io/Choices/

To Reproduce
Steps to reproduce the behavior:

  1. Create Multiple select input with some values
  2. Select all values into input - text "No choices to choose from" is displayed (that's fine)
  3. Remove at least one value from input
  4. Open select again and that option is (these options are) available to select, but also there is still text "No choices to choose from", see screenshot below.

Expected behavior

Text "No choices to choose from" should not be displayed when there are values, that can be selected.

Screenshots

image

Choices version and bundle

  • Version: v11.0.2 choices.js

Desktop:

  • OS: Windows 11
  • Browser Chrome
  • Version 128.0.6613.138

Additional context

My guess is, that it is caused by #1192.

I'm filling choices via Javascript so I came up with workaround, until this issue is fixed:

const choicesItems = [...]; // My items
const choices = new Choices(element, { // element is <select multiple></select>
	choices: choicesItems,
};
element.addEventListener('change', function () {
	if (choices.getValue().length !== choicesItems.length) {
		choices._clearNotice();
	}
});
@DJTommek DJTommek added the bug label Sep 26, 2024
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

1 participant