Choices-js / Choices

A vanilla JS customisable select box/text input plugin ⚡️
https://choices-js.github.io/Choices/
MIT License
6.25k stars 617 forks source link

Option to *not* fill the underlying select #1204

Open lianee opened 2 months ago

lianee commented 2 months ago

Is your feature request related to a problem? Please describe. Since v11, the underlying select element is filled with the options, even if the options are programmed. While this is not a problem with few options, it can be a huge load on the html page with many elements. Multiply this with a few controls and the page starts to crawl (I have a page with 11 choices and a lot of options that loaded instantly in v10 and now takes 45s to load).

Minimal example using v10 minimal example using v11

Describe the solution you'd like I'd like to have an option to revert to the previous behavior, i.e. not to put the options in the select element.

jhaltalingua commented 1 month ago

There is also a bug, where the underlying select is not cleaned up, when you execute following code twice. This just adds the items as option tags.

choices.setChoices(options, "value", "label", true);
choices.setChoices(options, "value", "label", true);

underlying select is not cleaned up too with clearChoices choices.clearChoices();

Its working in version 11.0.1