wenzhixin / multiple-select

A jQuery plugin to select multiple elements with checkboxes :)
http://multiple-select.wenzhixin.net.cn
MIT License
1.91k stars 651 forks source link

optgroup representation in .msdrop not toggled correct #557

Open IZSkiSurfer opened 4 years ago

IZSkiSurfer commented 4 years ago

In https://github.com/wenzhixin/multiple-select/blob/a49dd444ac3518a382c9ba2fdaed5488bad972a7/src/MultipleSelect.js#L737 we need to also search for span[data-key=${row._key}] to toggle the optgroup representation as well.

And in https://github.com/wenzhixin/multiple-select/blob/a49dd444ac3518a382c9ba2fdaed5488bad972a7/src/MultipleSelect.js#L233 we must convert selectedCount to boolean.

so replace row.selected = !this.options.single && selectedCount && selectedCount === with row.selected = !this.options.single && !!selectedCount && selectedCount ===

Atm row.selected will be evalutated to 0 if selectedCount is 0 and if we use this value in https://github.com/wenzhixin/multiple-select/blob/a49dd444ac3518a382c9ba2fdaed5488bad972a7/src/MultipleSelect.js#L737-L738 to toggle the class (and change prop) the class "selected" will be toggled and not removed (see https://api.jquery.com/toggleclass/#toggleClass-className-state which clearly states that the state must be boolean - not truthy/falsy)