Choices icon indicating copy to clipboard operation
Choices copied to clipboard

Duplicate selected values after multiple re-setting choices

Open YuriGor opened this issue 5 years ago • 5 comments

Hi, thank you for the cool widget! found a bug: setChoices with replaceChoices = true and preselected choice in the data leads to nonsense duplicated value:

<select multiple></select>
const element = document.querySelector('select');
const choices = new Choices(element);

choices.setChoices([
  {label:'Choice 1', value:'1'},
  {label:'Choice 2', value:'2', selected:true},
  {label:'Choice 3', value:'3'},
], undefined, undefined, true);

choices.setChoices([
  {label:'Choice 1', value:'1'},
  {label:'Choice 2', value:'2', selected:true},
  {label:'Choice 3', value:'3'},
], undefined, undefined, true);

image demo

YuriGor avatar Nov 10 '19 15:11 YuriGor

Hey - looks like the selected choice isn't being cleared. Thanks for raising

jshjohnson avatar Nov 12 '19 09:11 jshjohnson

Yes, as a workaround i load data without selected attr and set selected items via API separately.

YuriGor avatar Nov 12 '19 09:11 YuriGor

When this issue will be fixed? It's quite an important bug

Tim-arts avatar Feb 13 '20 22:02 Tim-arts

You can use .clearStore() as temporary solution

viladimiru avatar May 06 '22 10:05 viladimiru

Is this issue been resolved?

nkb-bd avatar May 23 '22 11:05 nkb-bd