Skip to content

Commit b3419c4

Browse files
committed
Stop event if readonly and keypress unless tab key
1 parent 2107de0 commit b3419c4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ export class UUISelectElement extends UUIFormControlMixin(LitElement, '') {
199199
);
200200
}
201201

202+
private handleOpenKeydown(e: KeyboardEvent) {
203+
if (this.readonly && e.key !== 'Tab') {
204+
e.preventDefault();
205+
e.stopPropagation();
206+
return;
207+
}
208+
}
209+
202210
private _renderOption(
203211
name: string,
204212
value: string,
@@ -244,6 +252,7 @@ export class UUISelectElement extends UUIFormControlMixin(LitElement, '') {
244252
id="native"
245253
aria-label=${this.label}
246254
@change=${this.setValue}
255+
@keydown=${this.handleOpenKeydown}
247256
?disabled=${this.disabled}
248257
aria-readonly=${this.readonly ? 'true' : 'false'}
249258
.name=${this.name}

0 commit comments

Comments
 (0)