From c45c8d5564a20fa5e7254edcaadd7b3ea2f8c61f Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 24 Nov 2020 14:31:24 -0500 Subject: [PATCH] fix(checkbox): click events on ion-item now fire properly (#22561) resolves #22557 --- core/src/components/checkbox/checkbox.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/src/components/checkbox/checkbox.tsx b/core/src/components/checkbox/checkbox.tsx index 750e7f28df0..86274858da7 100644 --- a/core/src/components/checkbox/checkbox.tsx +++ b/core/src/components/checkbox/checkbox.tsx @@ -114,10 +114,7 @@ export class Checkbox implements ComponentInterface { } } - private onClick = (ev: Event) => { - ev.preventDefault(); - ev.stopPropagation(); - + private onClick = () => { this.setFocus(); this.checked = !this.checked; this.indeterminate = false; @@ -171,6 +168,14 @@ export class Checkbox implements ComponentInterface { {labelText} { + {/** + * This is needed otherwise any click + * events set on `ion-item` are fired twice + */} + ev.preventDefault(); + ev.stopPropagation() + }} type="checkbox" aria-checked={`${checked}`} disabled={disabled}