How do I prevent the select2 from opening if I click on an actual tag?

I want to prevent the select2 from opening if you click directly on a tag. This kinda works but is buggy and looks dirty. Any better suggestions? Is there an originalEvent I can use? I can’t find one.

var tagClick = false;
$(document).on('mousedown', '.my-select2-tag-class', function(e) {
	var $self = $(this);
	tagClick = true;
});
$('#my-select2').select2(myOptions)
.on('select2:opening', function (e) {
	var $self = $(this);
	if( tagClick )
	{
		e.preventDefault();
		$self.select2('close');
		tagClick = false;
	}
});

I’m not intimately familiar with all the properties of all the synthetic events that Select2 provides. Have you inspected the select2:opening event to see whether it includes an originalEvent property? My guess (based on my experience with Select2) is that it doesn’t contain such a property. In that case you’re probably doing the best you can. You mentioned your solution was “buggy”, but you didn’t say exactly what that means. Can you be more specific? Alternatively, can you put a working code sample on jsfiddle.net or codepen.io so I can see how it behaves?