Skip to content

Commit 1fd0e1d

Browse files
authored
fix: support non-latin chars in list-mixin keyboard search (#6798)
1 parent 4e74838 commit 1fd0e1d

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎packages/a11y-base/src/list-mixin.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export const ListMixin = (superClass) =>
253253
const key = event.key;
254254

255255
const currentIdx = this.items.indexOf(this.focused);
256-
if (/[a-zA-Z0-9]/u.test(key) && key.length === 1) {
256+
if (/[\p{L}\p{Nd}]/u.test(key) && key.length === 1) {
257257
const idx = this._searchKey(currentIdx, key);
258258
if (idx >= 0) {
259259
this._focus(idx);

‎packages/a11y-base/test/list-mixin.test.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,25 @@ const runTests = (defineHelper, baseMixin) => {
515515
keyDownChar(list, 'b');
516516
expect(list.items[1].focused).to.be.true;
517517
});
518+
519+
describe('non-latin keys', () => {
520+
const LARGE = 'ใหญ่';
521+
const SMALL = 'เล็ก';
522+
523+
beforeEach(() => {
524+
list.items[0].textContent = LARGE;
525+
list.items[1].textContent = SMALL;
526+
list.items[1].removeAttribute('label');
527+
});
528+
529+
it('should select items when non-latin keys are pressed', () => {
530+
keyDownChar(list, SMALL.charAt(0));
531+
expect(list.items[1].focused).to.be.true;
532+
533+
keyDownChar(list, LARGE.charAt(0));
534+
expect(list.items[0].focused).to.be.true;
535+
});
536+
});
518537
});
519538

520539
describe('empty items', () => {

0 commit comments

Comments
 (0)