setChoices doesn't render choices on dropdown open
Opened this issue · 0 comments
viliusvsx commented
Describe the bug
When trying to set choices with setChoices() method, choices will not be shown when opening dropdown. I tried this with the 10.0.2 version, and that was not the case
To Reproduce
Just create any .html file and put the code I provide
<!doctype html>
<html>
<head>
<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@11.0.2/public/assets/scripts/choices.min.js"></script>
</head>
<body>
<div>
<select id="select"></select>
</div>
<script>
const select = new Choices(document.querySelector('#select'), {
maxItemCount: -1,
searchFloor: 0,
renderChoiceLimit: -1,
searchResultLimit: -1,
searchEnabled: true,
});
select.setChoices([
{
value: '120',
label: 'User Name',
selected: true
}
], 'value', 'label', true)
</script>
</body>
Expected behavior
I think, that when I set selected option by setChoices method, I except that when I open dropdown, I could see that option in list, without writing anything in search bar. I tried this with 10.0.2 version, and that was not the case. On dropdown open, I could see all choices that I set
Screenshots
I provided the html code, that you simply need to put in any html file
Choices version and bundle
- Version: v11.0.2 choices.min.js
Desktop (please complete the following information):
- OS: Windows
- Browser: Chrome
- Version: 128.0.6613.138