Duplicate selection remove both values in Select2 autocomplete


I have autocomplete field with values getting from remote source using ajax. If I select same value twice, both values get removed. Same behavior observed in example provided in Select2 site,
https://select2.org/tagging#tagging-with-multi-value-select-boxes. If I select orange two times, both get removed. How can I retain one value ?

I’m not sure what you mean by “select orange two times”. You can only select it once (the “tag” labeled “orange” is added to the entry field when you select it from the dropdown). If you open the dropdown you will also see “orange” is selected (it has a blue background). If you click on it again, “orange” becomes unselected—the blue background disappears and so does the “tag” labeled “orange”). This is the expected behavior of the widget.