multiselect icon indicating copy to clipboard operation
multiselect copied to clipboard

Optgroups are not sorted

Open ncelerier opened this issue 3 years ago • 2 comments

Hello,

If you look at this example: https://crlcu.github.io/multiselect/examples/optgroup.html

We have that:

<optgroup label="Swedish Cars">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
</optgroup>

And when we look at the rendered multiselect, we have this ordering:

Swedish Cars
   Saab
German Cars
   Audi
   Mercedes

So:

  • the optgroups are NOT sorted
  • the options inside the optgroup are sorted

Is there a way to have the optgroup sorted, and the option sorted at the same time, like that:

German Cars
   Audi
   Mercedes
Swedish Cars
   Saab

Am I missing an option or something ?

Thank you for your help!

ncelerier avatar Oct 23 '20 12:10 ncelerier

Hi @ncelerier

You are right - the default behaviour of this plugin is not sorting optgroups - only options. Anyway, I'm happy to accept pull requests from the community.

crlcu avatar Nov 30 '20 07:11 crlcu

Ok, thank you for clarifying.

ncelerier avatar Nov 30 '20 10:11 ncelerier