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

Resolve bug with Korean input handling #6295

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
15 changes: 13 additions & 2 deletions src/js/select2/dropdown/search.js
Expand Up @@ -48,9 +48,20 @@ define([
});

this.$search.on('keyup input', function (evt) {
self.handleSearch(evt);
// Set the current input value to an empty string if the previous value is undefined.
self.preTargetValue = self.preTargetValue === undefined ? "" : self.preTargetValue;

// In the case of Korean characters, the 'input' event can occur even when
// arrow keys or enter keys are pressed. Therefore, prevent additional actions
// and avoid duplicate searches if the value has not changed.
if (self.preTargetValue === evt.target.value) {
evt.preventDefault();
} else {
self.preTargetValue = evt.target.value;
self.handleSearch(evt);
}
});

container.on('open', function () {
self.$search.attr('tabindex', 0);
self.$search.attr('aria-controls', resultsId);
Expand Down