Skip to content

Commit

Permalink
refactor: check for unselected options when using tags and highlight …
Browse files Browse the repository at this point in the history
…that option first
  • Loading branch information
Martin Carlin committed Mar 25, 2020
1 parent 4bd4bbc commit e0d2795
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/js/select2/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,13 @@ define([
.find('.select2-results__option[aria-selected]');

var $selected = $options.filter('[aria-selected=true]');
var $unselected = $options.filter('[aria-selected=false]');

// Check if there are any selected options
if ($selected.length > 0) {
// Check if there are any unselected options in tags mode
if ($unselected.length > 0 && this.options.get('tags')) {
$unselected.last().trigger('mouseenter');
} else if ($selected.length > 0) {
// Check if there are any selected options
// If there are selected options, highlight the first
$selected.first().trigger('mouseenter');
} else {
Expand Down

0 comments on commit e0d2795

Please sign in to comment.