Don't force highlight nothing element

Causes "Uncaught TypeError: Cannot read property 'element' of undefined at DecoratedClass.SelectOnClose._handleSelectOnClose"

Refs #4867
This commit is contained in:
Samuel Georges 2020-01-07 07:04:09 +11:00
parent 64d7464ed3
commit d46accfc4f
2 changed files with 6 additions and 4 deletions

View File

@ -126,8 +126,10 @@
extraOptions.minimumInputLength = 1
$element.on('select2:closing', function() {
$('.select2-dropdown.select-no-dropdown:first .select2-results__option--highlighted').removeClass('select2-results__option--highlighted')
$('.select2-dropdown.select-no-dropdown:first .select2-results__option:first').addClass('select2-results__option--highlighted')
if ($('.select2-dropdown.select-no-dropdown:first .select2-results__option--highlighted').length > 0) {
$('.select2-dropdown.select-no-dropdown:first .select2-results__option--highlighted').removeClass('select2-results__option--highlighted')
$('.select2-dropdown.select-no-dropdown:first .select2-results__option:first').addClass('select2-results__option--highlighted')
}
})
}
}

View File

@ -3527,8 +3527,8 @@ extraOptions.tokenSeparators=separators.split('|')
if($element.hasClass('select-no-dropdown')){extraOptions.selectOnClose=true
extraOptions.closeOnSelect=false
extraOptions.minimumInputLength=1
$element.on('select2:closing',function(){$('.select2-dropdown.select-no-dropdown:first .select2-results__option--highlighted').removeClass('select2-results__option--highlighted')
$('.select2-dropdown.select-no-dropdown:first .select2-results__option:first').addClass('select2-results__option--highlighted')})}}
$element.on('select2:closing',function(){if($('.select2-dropdown.select-no-dropdown:first .select2-results__option--highlighted').length>0){$('.select2-dropdown.select-no-dropdown:first .select2-results__option--highlighted').removeClass('select2-results__option--highlighted')
$('.select2-dropdown.select-no-dropdown:first .select2-results__option:first').addClass('select2-results__option--highlighted')}})}}
var placeholder=$element.data('placeholder')
if(placeholder){extraOptions.placeholder=placeholder
extraOptions.allowClear=true}