Skip to content

Commit e5cd7b4

Browse files
committed
Changed e.key for e.code for more consistency.
1 parent 4972096 commit e5cd7b4

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

packages/uui-combobox-list/lib/uui-combobox-list.element.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export class UUIComboboxListElement extends LitElement {
207207
private _onKeyDown = (e: KeyboardEvent) => {
208208
if (this._options.length <= 0) return;
209209

210-
switch (e.key) {
210+
switch (e.code) {
211211
case 'ArrowUp':
212212
e.preventDefault();
213213
if (e.ctrlKey) {
@@ -240,8 +240,7 @@ export class UUIComboboxListElement extends LitElement {
240240
}
241241

242242
//Space key
243-
case ' ': {
244-
const el = e.target as HTMLInputElement;
243+
case 'Space': {
245244
e.preventDefault();
246245
e.stopPropagation();
247246
this._getActiveElement?.click();

packages/uui-combobox/lib/uui-combobox.element.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,23 +298,23 @@ export class UUIComboboxElement extends UUIFormControlMixin(LitElement, '') {
298298
};
299299

300300
#onKeyDown = (e: KeyboardEvent) => {
301-
if (this.open === false && e.key === 'Enter') {
301+
if (this.open === false && e.code === 'Enter') {
302302
e.preventDefault(); // TODO: could we avoid this.
303303
e.stopImmediatePropagation(); // TODO: could we avoid this.
304304
}
305305

306-
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
306+
if (e.code === 'ArrowUp' || e.code === 'ArrowDown') {
307307
this.#onOpen();
308308
}
309309

310-
if (e.key === ' ') {
310+
if (e.code === 'Space') {
311311
if (this._isOpen) return;
312312
e.preventDefault();
313313
e.stopImmediatePropagation();
314314
this.#onOpen();
315315
}
316316

317-
if (e.key === 'Escape' || e.key === 'Enter') {
317+
if (e.code === 'Escape' || e.code === 'Enter') {
318318
this.#onClose();
319319
}
320320
};

0 commit comments

Comments
 (0)