diff --git a/core/src/components/checkbox/checkbox.tsx b/core/src/components/checkbox/checkbox.tsx index 00a9de5c7cf..22f3959fba7 100644 --- a/core/src/components/checkbox/checkbox.tsx +++ b/core/src/components/checkbox/checkbox.tsx @@ -34,7 +34,6 @@ export class Checkbox implements ComponentInterface { private inputLabelId = `${this.inputId}-lbl`; private helperTextId = `${this.inputId}-helper-text`; private errorTextId = `${this.inputId}-error-text`; - private focusEl?: HTMLElement; private inheritedAttributes: Attributes = {}; @Element() el!: HTMLIonCheckboxElement; @@ -147,9 +146,7 @@ export class Checkbox implements ComponentInterface { /** @internal */ @Method() async setFocus() { - if (this.focusEl) { - this.focusEl.focus(); - } + this.el.focus(); } /** @@ -169,7 +166,6 @@ export class Checkbox implements ComponentInterface { private toggleChecked = (ev: Event) => { ev.preventDefault(); - this.setFocus(); this.setChecked(!this.checked); this.indeterminate = false; }; @@ -285,6 +281,9 @@ export class Checkbox implements ComponentInterface { aria-disabled={disabled ? 'true' : null} tabindex={disabled ? undefined : 0} onKeyDown={this.onKeyDown} + onFocus={this.onFocus} + onBlur={this.onBlur} + onClick={this.onClick} class={createColorClasses(color, { [mode]: true, 'in-item': hostContext('ion-item', el), @@ -296,7 +295,6 @@ export class Checkbox implements ComponentInterface { [`checkbox-alignment-${alignment}`]: alignment !== undefined, [`checkbox-label-placement-${labelPlacement}`]: true, })} - onClick={this.onClick} >