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

setChoices doesn't render choices on dropdown open #1203

Open
viliusvsx opened this issue Sep 13, 2024 · 0 comments
Open

setChoices doesn't render choices on dropdown open #1203

viliusvsx opened this issue Sep 13, 2024 · 0 comments
Assignees
Labels

Comments

@viliusvsx
Copy link

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/[email protected]/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
@viliusvsx viliusvsx added the bug label Sep 13, 2024
@Xon Xon self-assigned this Sep 18, 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

2 participants