Please refer to Github for the same.
Prevent select2: open when cleaning selection
From there, I listed the answers provided.
1 option
$('#select-id').on('select2:unselecting', function() { var opts = $(this).data('select2').options; opts.set('disabled', true); setTimeout(function() { opts.set('disabled', false); }, 1); });
Option 2
var $el = $('#select-id'); $el.on('select2:unselecting', function(e) { $el.data('unselecting', true); }).on('select2:open', function(e) { // note the open event is important if ($el.data('unselecting')) { $el.removeData('unselecting'); // you need to unset this before close $el.select2('close'); } });
source share