Skip to content

Commit cee8c18

Browse files
committed
Change how the results are highlighted
Previously, a result was no longer highlighted when the mouse was no longer over it. While this was useful for resetting the highlight automatically, we started doing this when a new result was highlighted to make sure that we never had multiple options highlighted. Now, a result will always be highlighted until the highlight is removed when the next result is highlighted. While this shouldn't affect many users, it is closer to how native select boxes work. This also allows users using keyboard navigation to jump between mouse and keyboard navigation without the highlight reseting to the top of the results.
1 parent 849a9c7 commit cee8c18

7 files changed

Lines changed: 3 additions & 38 deletions

File tree

dist/js/select2.amd.full.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,6 @@ define('select2/results',[
511511
element: $(this)
512512
});
513513
});
514-
515-
this.$results.on('mouseleave', '.option', function (evt) {
516-
if ($(this).hasClass('highlighted')) {
517-
$(this).removeClass('highlighted');
518-
self.$results.removeAttr('aria-activedescendant');
519-
}
520-
});
521514
};
522515

523516
Results.prototype.destroy = function () {

dist/js/select2.amd.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,6 @@ define('select2/results',[
511511
element: $(this)
512512
});
513513
});
514-
515-
this.$results.on('mouseleave', '.option', function (evt) {
516-
if ($(this).hasClass('highlighted')) {
517-
$(this).removeClass('highlighted');
518-
self.$results.removeAttr('aria-activedescendant');
519-
}
520-
});
521514
};
522515

523516
Results.prototype.destroy = function () {

dist/js/select2.full.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10046,13 +10046,6 @@ define('select2/results',[
1004610046
element: $(this)
1004710047
});
1004810048
});
10049-
10050-
this.$results.on('mouseleave', '.option', function (evt) {
10051-
if ($(this).hasClass('highlighted')) {
10052-
$(this).removeClass('highlighted');
10053-
self.$results.removeAttr('aria-activedescendant');
10054-
}
10055-
});
1005610049
};
1005710050

1005810051
Results.prototype.destroy = function () {

dist/js/select2.full.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/select2.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -939,13 +939,6 @@ define('select2/results',[
939939
element: $(this)
940940
});
941941
});
942-
943-
this.$results.on('mouseleave', '.option', function (evt) {
944-
if ($(this).hasClass('highlighted')) {
945-
$(this).removeClass('highlighted');
946-
self.$results.removeAttr('aria-activedescendant');
947-
}
948-
});
949942
};
950943

951944
Results.prototype.destroy = function () {

dist/js/select2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/select2/results.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,6 @@ define([
357357
element: $(this)
358358
});
359359
});
360-
361-
this.$results.on('mouseleave', '.option', function (evt) {
362-
if ($(this).hasClass('highlighted')) {
363-
$(this).removeClass('highlighted');
364-
self.$results.removeAttr('aria-activedescendant');
365-
}
366-
});
367360
};
368361

369362
Results.prototype.destroy = function () {

0 commit comments

Comments
 (0)