andreww1011 / filter-multi-select

Multiple select dropdown with filter jQuery plugin.
Other
28 stars 15 forks source link

Respect optgroups in select #28

Open christinaellen opened 11 months ago

christinaellen commented 11 months ago

I have a lot of options with same names categorized by optgroups in a normal select input. Using optgroup with the multi-filter plugin seems to ignore the optgroups and just lists out all the options together.

Adding something like a .dropdown-item.optgroup-control between the checkbox groups for the optgroup labels would be most helpful.

christinaellen commented 11 months ago

If anyone else is running into the same issue, the current "solution" I've come up with is to add disabled options acting as optgroup labels, and customizing the styles for disabled input labels as such:

.filter-multi-select .custom-control-input:disabled ~ .custom-control-label {
    margin-left: -44px;
    margin-top: 8px;
    padding-left: 20px;
    font-weight: 700;
    color: #93a4ac;
}

This hides the disabled checkbox and makes the option look more like a label/heading for the options below. Obviously this will not work when you actually need to have disabled options, but in my case this is sufficient.

The "filter" function will also not retain the "labels" so if you search for any options that have the same name you will have to guess/remember which category they are under solely by the order they appear.

Again, I'm considering this a "non-issue" for my implementation, but it would be nice to have a way to create labels automatically with optgroups from the select.