select2 多选情况下不自动关闭,并禁用 First Item 高亮

This commit is contained in:
thinkgem
2020-03-21 22:09:49 +08:00
parent f79b18a4b9
commit f08a252b51

View File

@@ -857,22 +857,23 @@ S2.define('select2/results',[
}; };
Results.prototype.highlightFirstItem = function () { Results.prototype.highlightFirstItem = function () {
var $options = this.$results // var $options = this.$results
.find('.select2-results__option[aria-selected]'); // .find('.select2-results__option[aria-selected]');
//
var $selected = $options.filter('[aria-selected=true]'); // var $selected = $options.filter('[aria-selected=true]');
//
// Check if there are any selected options // // Check if there are any selected options
if ($selected.length > 0) { // if ($selected.length > 0) {
// If there are selected options, highlight the first // // If there are selected options, highlight the first
$selected.first().trigger('mouseenter'); // $selected.first().trigger('mouseenter');
} else { // } else {
// If there are no selected options, highlight the first option // // If there are no selected options, highlight the first option
// in the dropdown // // in the dropdown
$options.first().trigger('mouseenter'); // $options.first().trigger('mouseenter');
} // }
//
this.ensureHighlightVisible(); // this.ensureHighlightVisible();
// ThinkGem 禁用 First Item 高亮
}; };
Results.prototype.setClasses = function () { Results.prototype.setClasses = function () {