Renamed focusFirstItem method
This renames the `focusFirstItem` method to `highlightFirstItem`, which better reflects what is actually happening. This also ensures that the highlight is visible when it is moved by calling `ensureHighlightVisible`. This closes https://github.com/select2/select2/issues/3479 This closes https://github.com/select2/select2/pull/4238
This commit is contained in:
parent
e897d008a6
commit
9f581285d8
10
src/js/select2/results.js
vendored
10
src/js/select2/results.js
vendored
@ -97,8 +97,7 @@ define([
|
||||
return sorter(data);
|
||||
};
|
||||
|
||||
Results.prototype.focusFirstItem = function () {
|
||||
|
||||
Results.prototype.highlightFirstItem = function () {
|
||||
var $options = this.$results
|
||||
.find('.select2-results__option[aria-selected]');
|
||||
|
||||
@ -114,6 +113,7 @@ define([
|
||||
$options.first().trigger('mouseenter');
|
||||
}
|
||||
|
||||
this.ensureHighlightVisible();
|
||||
};
|
||||
|
||||
Results.prototype.setClasses = function () {
|
||||
@ -253,7 +253,7 @@ define([
|
||||
|
||||
if (container.isOpen()) {
|
||||
self.setClasses();
|
||||
self.focusFirstItem();
|
||||
self.highlightFirstItem();
|
||||
}
|
||||
});
|
||||
|
||||
@ -276,7 +276,7 @@ define([
|
||||
}
|
||||
|
||||
self.setClasses();
|
||||
self.focusFirstItem();
|
||||
self.highlightFirstItem();
|
||||
});
|
||||
|
||||
container.on('unselect', function () {
|
||||
@ -285,7 +285,7 @@ define([
|
||||
}
|
||||
|
||||
self.setClasses();
|
||||
self.focusFirstItem();
|
||||
self.highlightFirstItem();
|
||||
});
|
||||
|
||||
container.on('open', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user