Fixed infinite scrolling issue using down key.
This commit is contained in:
parent
07aa8a45b0
commit
e897d008a6
33
src/js/select2/results.js
vendored
33
src/js/select2/results.js
vendored
@ -97,6 +97,25 @@ define([
|
||||
return sorter(data);
|
||||
};
|
||||
|
||||
Results.prototype.focusFirstItem = function () {
|
||||
|
||||
var $options = this.$results
|
||||
.find('.select2-results__option[aria-selected]');
|
||||
|
||||
var $selected = $options.filter('[aria-selected=true]');
|
||||
|
||||
// Check if there are any selected options
|
||||
if ($selected.length > 0) {
|
||||
// If there are selected options, highlight the first
|
||||
$selected.first().trigger('mouseenter');
|
||||
} else {
|
||||
// If there are no selected options, highlight the first option
|
||||
// in the dropdown
|
||||
$options.first().trigger('mouseenter');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Results.prototype.setClasses = function () {
|
||||
var self = this;
|
||||
|
||||
@ -124,17 +143,6 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
var $selected = $options.filter('[aria-selected=true]');
|
||||
|
||||
// Check if there are any selected options
|
||||
if ($selected.length > 0) {
|
||||
// If there are selected options, highlight the first
|
||||
$selected.first().trigger('mouseenter');
|
||||
} else {
|
||||
// If there are no selected options, highlight the first option
|
||||
// in the dropdown
|
||||
$options.first().trigger('mouseenter');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -245,6 +253,7 @@ define([
|
||||
|
||||
if (container.isOpen()) {
|
||||
self.setClasses();
|
||||
self.focusFirstItem();
|
||||
}
|
||||
});
|
||||
|
||||
@ -267,6 +276,7 @@ define([
|
||||
}
|
||||
|
||||
self.setClasses();
|
||||
self.focusFirstItem();
|
||||
});
|
||||
|
||||
container.on('unselect', function () {
|
||||
@ -275,6 +285,7 @@ define([
|
||||
}
|
||||
|
||||
self.setClasses();
|
||||
self.focusFirstItem();
|
||||
});
|
||||
|
||||
container.on('open', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user