Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including the original event on enter key press and passing it along to final triggers #5758

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/js/select2/core.js
Expand Up @@ -335,7 +335,9 @@ define([

evt.preventDefault();
} else if (key === KEYS.ENTER) {
self.trigger('results:select', {});
self.trigger('results:select', {
originalEvent: evt
});

evt.preventDefault();
} else if ((key === KEYS.SPACE && evt.ctrlKey)) {
Expand Down
7 changes: 5 additions & 2 deletions src/js/select2/results.js
Expand Up @@ -325,7 +325,7 @@ define([
$highlighted.trigger('mouseup');
});

container.on('results:select', function () {
container.on('results:select', function (evt) {
var $highlighted = self.getHighlightedResults();

if ($highlighted.length === 0) {
Expand All @@ -335,9 +335,12 @@ define([
var data = Utils.GetData($highlighted[0], 'data');

if ($highlighted.attr('aria-selected') == 'true') {
self.trigger('close', {});
self.trigger('close', {
originalEvent: evt.originalEvent
});
} else {
self.trigger('select', {
originalEvent: evt.originalEvent,
data: data
});
}
Expand Down