Open IZSkiSurfer opened 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.
span[data-key=${row._key}]
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 ===
row.selected = !this.options.single && selectedCount && selectedCount ===
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)
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 ===
withrow.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)