When adding a new tag option, after two keypresses, an existing option is (incorrectly) selected


#1

I recently updated a site that uses select2 to handle tagging an entity, with a select2 dropdown with multiple options and the user can add new options with the ‘tags’ feature. This worked fine previous to the update to “select2”: “^4.0.10” (i think the old version was ^4.0.6-rc.1")

Now when I try to type a new tag in order to add it, after typing two characters, the control automatically selects one of the options that is already in the list, any I cannot finish typing the new tag.

I’m using a dynamically added config, and so my code to add the tag via laravel is:
{!! Form::select(‘tag_list[]’, $tags, null, [
‘id’ = > ‘tag_list’,
‘class’ => ‘form-control select2’,
‘data-placeholder’ => ’ Choose a tag’,
‘data-tags’ => ‘true’,
‘multiple’ => ‘multiple’]) !!}


#2

After wracking my head about this, I realized I wasn’t using the latest version. Once I updated, this worked again.