diff --git a/src/js/select2/core.js b/src/js/select2/core.js index af48de5e..d42c4ead 100644 --- a/src/js/select2/core.js +++ b/src/js/select2/core.js @@ -357,7 +357,7 @@ define([ 'select': 'selecting', 'unselect': 'unselecting' }; - + if (args === undefined) { args = {}; } diff --git a/src/js/select2/dropdown/selectOnClose.js b/src/js/select2/dropdown/selectOnClose.js index 763d18a2..ee45de10 100644 --- a/src/js/select2/dropdown/selectOnClose.js +++ b/src/js/select2/dropdown/selectOnClose.js @@ -16,12 +16,23 @@ define([ SelectOnClose.prototype._handleSelectOnClose = function () { var $highlightedResults = this.getHighlightedResults(); + // Only select highlighted results if ($highlightedResults.length < 1) { return; } + var data = $highlightedResults.data('data'); + + // Don't re-select already selected resulte + if ( + (data.element != null && data.element.selected) || + (data.element == null && data.selected) + ) { + return; + } + this.trigger('select', { - data: $highlightedResults.data('data') + data: data }); };