Add focus method to SlSelect (#625)

pull/629/head
ErikOnBike 2021-12-17 15:15:47 +01:00 zatwierdzone przez GitHub
rodzic 125392ce57
commit d6d05121e4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

@ -179,6 +179,12 @@ export default class SlSelect extends LitElement {
return Array.isArray(this.value) ? this.value : [this.value];
}
/** Sets focus on the control. */
focus(options?: FocusOptions) {
const box = this.shadowRoot?.querySelector('.select__control') as HTMLElement;
box.focus(options);
}
handleBlur() {
// Don't blur if the control is open. We'll move focus back once it closes.
if (!this.isOpen) {
@ -271,8 +277,7 @@ export default class SlSelect extends LitElement {
}
handleLabelClick() {
const box = this.shadowRoot?.querySelector('.select__control') as HTMLElement;
box.focus();
this.focus();
}
handleMenuSelect(event: CustomEvent) {