Skip to content

Commit

Permalink
fix(material/checkbox): focus not moved to input when clicking on tou…
Browse files Browse the repository at this point in the history
…ch target

Fixes that while we were toggling the checked state of a checkbox when its touch target is clicked, we weren't moving focus to the internal `input`.

Fixes #26486.
  • Loading branch information
crisbeto committed Feb 1, 2023
1 parent d181eb9 commit 99a5a49
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/material/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ export abstract class _MatCheckboxBase<E>
});
}

// Normally the input should be focused already, but if the click comes from something
// like the touch target, then we might have to focus it ourselves.
this._inputElement.nativeElement.focus();
this._checked = !this._checked;
this._transitionCheckState(
this._checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked,
Expand Down

0 comments on commit 99a5a49

Please sign in to comment.