Fixes removal of first item from taglist
Tested #4867 but it broke the use of pressing TAB after entering a tag to lock it in. This seems to retain that functionality and yet still fix the issue Replaces #4867
This commit is contained in:
parent
4a1295162c
commit
ec0918e284
|
|
@ -124,7 +124,16 @@
|
|||
extraOptions.selectOnClose = true
|
||||
extraOptions.closeOnSelect = false
|
||||
|
||||
var unselecting = false
|
||||
$element.on('select2:unselect', function() {
|
||||
unselecting = true
|
||||
})
|
||||
$element.on('select2:open', function() {
|
||||
unselecting = false
|
||||
})
|
||||
|
||||
$element.on('select2:closing', function() {
|
||||
if (unselecting) return
|
||||
$('.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')
|
||||
})
|
||||
|
|
|
|||
|
|
@ -3526,7 +3526,11 @@ if(separators){extraOptions.tags=true
|
|||
extraOptions.tokenSeparators=separators.split('|')
|
||||
if($element.hasClass('select-no-dropdown')){extraOptions.selectOnClose=true
|
||||
extraOptions.closeOnSelect=false
|
||||
$element.on('select2:closing',function(){$('.select2-dropdown.select-no-dropdown:first .select2-results__option--highlighted').removeClass('select2-results__option--highlighted')
|
||||
var unselecting=false
|
||||
$element.on('select2:unselect',function(){unselecting=true})
|
||||
$element.on('select2:open',function(){unselecting=false})
|
||||
$element.on('select2:closing',function(){if(unselecting)return
|
||||
$('.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
|
||||
|
|
|
|||
Loading…
Reference in New Issue