Change select2 auto-selected tag when creating a new tag

I am using select2, I have a setup so I can create new tags if they don't exist.

This all works great, but I have one mistake - that the "new tag" is an auto-selected tag, which causes a lot of bogus, randomly generated tags.

I want the "new tag" to show at the top as usual,

But, if there are other fit options, then the closest match needs to be selected, then the user can click the up arrow if they want to create a new tag.

This is what I want to show when typing "scrum" when the "scrums" tag already exists:

optimal choice

+3


source to share


1 answer


I know this is old, but I approached this question looking for something else.

By default, the first matching option is selected for automatic selection. Here, as far as I can see, "Scrum" precedes "Scrums" when sorted in ascending order. This is why he chooses "Scrum" (no "s" at the end). If the newly created option was "Scrumss" and there was no "Scrum" option in the parameters, then "Scrums" is automatically selected.



I think you understood your problem, but didn't want to leave the question unanswered :)

Please post a comment if this is not a problem or if I was wrong.

0


source







All Articles