In multiselect "No choices to choose from" is sometimes displayed even if there are choices
Closed this issue · 0 comments
DJTommek commented
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:
- Create Multiple select input with some values
- Select all values into input - text "No choices to choose from" is displayed (that's fine)
- Remove at least one value from input
- 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
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();
}
});