kopia lustrzana https://github.com/shoelace-style/shoelace
Add focus method to SlSelect (#625)
rodzic
125392ce57
commit
d6d05121e4
|
@ -179,6 +179,12 @@ export default class SlSelect extends LitElement {
|
||||||
return Array.isArray(this.value) ? this.value : [this.value];
|
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() {
|
handleBlur() {
|
||||||
// Don't blur if the control is open. We'll move focus back once it closes.
|
// Don't blur if the control is open. We'll move focus back once it closes.
|
||||||
if (!this.isOpen) {
|
if (!this.isOpen) {
|
||||||
|
@ -271,8 +277,7 @@ export default class SlSelect extends LitElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLabelClick() {
|
handleLabelClick() {
|
||||||
const box = this.shadowRoot?.querySelector('.select__control') as HTMLElement;
|
this.focus();
|
||||||
box.focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMenuSelect(event: CustomEvent) {
|
handleMenuSelect(event: CustomEvent) {
|
||||||
|
|
Ładowanie…
Reference in New Issue