add blur()

This commit is contained in:
Cory LaViska
2021-12-17 09:27:23 -05:00
parent d6d05121e4
commit e2012433cb
3 changed files with 9 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ describe('<sl-select>', () => {
expect(changeHandler).to.have.been.calledOnce;
});
it('should open the menu when any letter key is pressed with sl-select is on focus', async () => {
it('should open the menu when any letter key is pressed with sl-select is on focus', async () => {
const el = (await fixture(html`
<sl-select>
<sl-menu-item value="option-1">Option 1</sl-menu-item>

View File

@@ -181,8 +181,12 @@ export default class SlSelect extends LitElement {
/** Sets focus on the control. */
focus(options?: FocusOptions) {
const box = this.shadowRoot?.querySelector('.select__control') as HTMLElement;
box.focus(options);
this.control.focus(options);
}
/** Removes focus from the control. */
blur() {
this.control.blur();
}
handleBlur() {
@@ -452,7 +456,7 @@ export default class SlSelect extends LitElement {
part="base"
.hoist=${this.hoist}
.stayOpenOnSelect=${this.multiple}
.containingElement=${this}
.containingElement=${this as HTMLElement}
?disabled=${this.disabled}
class=${classMap({
select: true,