bluzky/nice-select2

updateSelectValue multiple issue

Opened this issue · 2 comments

When user check and uncheck item, in native select, option doesn't remove attribute selected=true.

You can fix it by:

var select = this.el;
select.querySelectorAll("option").forEach(function (item) {
  item.removeAttribute("selected");
});
this.selectedOptions.forEach(function(item) {
  var el = select.querySelector(`option[value="${item.data.value}"]`);
  if (el){
    //Change it, cause it works more correctly.
    el.setAttribute("selected", "selected");
    el.selected = true;
  }
});

Or some better solution with indexOf, filter.

+1 on this. This would be so nice

+1 on this. This would be so nice

If you are looking for a new and supported library for selectors in native JavaScript, I can recommend you my own, which I am following.