|
@@ -97,6 +97,25 @@ define([
|
|
return sorter(data);
|
|
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 () {
|
|
Results.prototype.setClasses = function () {
|
|
var self = this;
|
|
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()) {
|
|
if (container.isOpen()) {
|
|
self.setClasses();
|
|
self.setClasses();
|
|
|
|
+ self.focusFirstItem();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -267,6 +276,7 @@ define([
|
|
}
|
|
}
|
|
|
|
|
|
self.setClasses();
|
|
self.setClasses();
|
|
|
|
+ self.focusFirstItem();
|
|
});
|
|
});
|
|
|
|
|
|
container.on('unselect', function () {
|
|
container.on('unselect', function () {
|
|
@@ -275,6 +285,7 @@ define([
|
|
}
|
|
}
|
|
|
|
|
|
self.setClasses();
|
|
self.setClasses();
|
|
|
|
+ self.focusFirstItem();
|
|
});
|
|
});
|
|
|
|
|
|
container.on('open', function () {
|
|
container.on('open', function () {
|