#6465·select2

Keyboard navigation (results:next) does not advance to or trigger infinite scroll .select2-results__option--load-more

Author: SnippyCodesCreated Sep 23, 2026Updated Sep 23, 2026

Description

In Select2 4.1.0, keyboard arrow navigation (results:previous and results:next in src/js/select2/results.js) was updated to only query:

javascript
var $options = self.$results.find('.select2-results__option--selectable');

When using AJAX data with pagination (infinite scroll), the bottom element is rendered with:

xml
<li class="select2-results__option select2-results__option--load-more" role="option" aria-disabled="true">
  Loading more results…
</li>

Because .select2-results__option--load-more does not have the --selectable modifier class, pressing ArrowDown at the end of the current page halts navigation at index = $options.length - 1.

Steps to Reproduce

  1. Configure Select2 with an AJAX data source that returns paginated results (pagination: { more: true }).
  2. Open the dropdown and navigate through results using the ArrowDown key.
  3. Reach the last option of the first page and press ArrowDown again.

Expected Behavior

Pressing ArrowDown past the last option should either focus the load-more element or scroll it into view to trigger loadMoreIfNeeded(), allowing keyboard-only users to seamlessly paginate through AJAX results.

Actual Behavior

results:next hits if (nextIndex >= $options.length) { return; } and halts. Keyboard-driven infinite scrolling cannot advance to subsequent pages.

Environment

  • Select2 Version: 4.1.0
  • Browsers: All (Chrome, Firefox, Safari)

Proposed Solution

In src/js/select2/results.js (under both results:previous and results:next), include .select2-results__option--load-more in $options:

javascript
var $options = self.$results.find(
  '.select2-results__option--selectable, .select2-results__option--load-more'
);

Alternatively, trigger loadMoreIfNeeded() when nextIndex >= $options.length.