1
0
mirror of synced 2024-11-22 13:06:08 +03:00

Fixed infinite scrolling issue using down key.

This commit is contained in:
Alexander Leonov 2016-03-02 14:53:05 -05:00 committed by Kevin Brown
parent 07aa8a45b0
commit e897d008a6

View File

@ -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 () {