Skip to content

Commit

Permalink
[BUGFIX] Fix support for non-Latin characters (#1072)
Browse files Browse the repository at this point in the history
* solve 1068

* resolve problems

* resolve npm problem

* Merge master and rebuild, fix lint error

* Create fresh package-lock.json

Co-authored-by: محمدرضا ضربی زاده <mohammad.zarbizadeh@samim.net>
Co-authored-by: Matt Triff <matt.triff@gmail.com>
  • Loading branch information
3 people authored Nov 29, 2022
1 parent a7ed4d8 commit 312971a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions public/assets/scripts/choices.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,8 @@ var Choices = /** @class */function () {
var hasActiveDropdown = this.dropdown.isActive;
var hasItems = this.itemList.hasChildren();
var keyString = String.fromCharCode(keyCode);
var wasAlphaNumericChar = /[a-zA-Z0-9-_ ]/.test(keyString);
// eslint-disable-next-line no-control-regex
var wasPrintableChar = /[^\x00-\x1F]/.test(keyString);
var BACK_KEY = constants_1.KEY_CODES.BACK_KEY,
DELETE_KEY = constants_1.KEY_CODES.DELETE_KEY,
ENTER_KEY = constants_1.KEY_CODES.ENTER_KEY,
Expand All @@ -1274,15 +1275,15 @@ var Choices = /** @class */function () {
DOWN_KEY = constants_1.KEY_CODES.DOWN_KEY,
PAGE_UP_KEY = constants_1.KEY_CODES.PAGE_UP_KEY,
PAGE_DOWN_KEY = constants_1.KEY_CODES.PAGE_DOWN_KEY;
if (!this._isTextElement && !hasActiveDropdown && wasAlphaNumericChar) {
if (!this._isTextElement && !hasActiveDropdown && wasPrintableChar) {
this.showDropdown();
if (!this.input.isFocussed) {
/*
We update the input value with the pressed key as
the input was not focussed at the time of key press
therefore does not have the value of the key.
*/
this.input.value += keyString.toLowerCase();
this.input.value += event.key.toLowerCase();
}
}
switch (keyCode) {
Expand Down
2 changes: 1 addition & 1 deletion public/assets/scripts/choices.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/types/src/scripts/choices.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/scripts/choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,8 @@ class Choices implements Choices {
const hasActiveDropdown = this.dropdown.isActive;
const hasItems = this.itemList.hasChildren();
const keyString = String.fromCharCode(keyCode);
const wasAlphaNumericChar = /[a-zA-Z0-9-_ ]/.test(keyString);
// eslint-disable-next-line no-control-regex
const wasPrintableChar = /[^\x00-\x1F]/.test(keyString);

const {
BACK_KEY,
Expand All @@ -1455,7 +1456,7 @@ class Choices implements Choices {
PAGE_DOWN_KEY,
} = KEY_CODES;

if (!this._isTextElement && !hasActiveDropdown && wasAlphaNumericChar) {
if (!this._isTextElement && !hasActiveDropdown && wasPrintableChar) {
this.showDropdown();

if (!this.input.isFocussed) {
Expand All @@ -1464,7 +1465,7 @@ class Choices implements Choices {
the input was not focussed at the time of key press
therefore does not have the value of the key.
*/
this.input.value += keyString.toLowerCase();
this.input.value += event.key.toLowerCase();
}
}

Expand Down

0 comments on commit 312971a

Please sign in to comment.