diff --git a/mwui-stencil/src/components/mw-switch/mw-switch.tsx b/mwui-stencil/src/components/mw-switch/mw-switch.tsx index e00b0e0c..b7774c1d 100644 --- a/mwui-stencil/src/components/mw-switch/mw-switch.tsx +++ b/mwui-stencil/src/components/mw-switch/mw-switch.tsx @@ -37,16 +37,17 @@ export class MwSwitch { */ @Event({ bubbles: true, - cancelable: false, - composed: false, + composed: true, }) - emitter: EventEmitter; + emitter: EventEmitter; - private toggleSwitch(event: Event & { path: unknown[] }): void { - (event.target as HTMLInputElement).blur(); - this.checked = this.checkbox.checked; - this.emitter.emit(event); - } + private toggleSwitch = (event: Event): void => { + if (!this.disabled) { + (event.target as HTMLInputElement).blur(); + this.checked = !this.checked; + this.emitter.emit(this.checked); + } + }; private hasLabel: boolean; private hasOnOffLabel: boolean; @@ -59,8 +60,8 @@ export class MwSwitch { render() { return ( -