Skip to content

Commit

Permalink
fix(checkbox): click events on ion-item now fire properly (#22561)
Browse files Browse the repository at this point in the history
resolves #22557
  • Loading branch information
liamdebeasi committed Nov 24, 2020
1 parent afcc46e commit c45c8d5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/src/components/checkbox/checkbox.tsx
Expand Up @@ -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;
Expand Down Expand Up @@ -171,6 +168,14 @@ export class Checkbox implements ComponentInterface {
{labelText}
</label>
<input
onClick={(ev: Event) => {
{/**
* 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}
Expand Down

3 comments on commit c45c8d5

@DavidWiesner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevent a click event on a native input element could be problematic for a11y

@liamdebeasi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! I am reverting the commit until I can find a proper solution to the original issue.

@liamdebeasi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed via 0786835

Please sign in to comment.