From 455bac83ffb204d7cd1554ac16b183ea62114eaa Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Wed, 1 Feb 2023 14:49:03 +0100 Subject: [PATCH] fix(material/checkbox): focus not moved to input when clicking on touch 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. --- src/material/checkbox/checkbox.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/material/checkbox/checkbox.ts b/src/material/checkbox/checkbox.ts index c32946fd88d1..14847e4f5a76 100644 --- a/src/material/checkbox/checkbox.ts +++ b/src/material/checkbox/checkbox.ts @@ -380,6 +380,9 @@ export abstract class _MatCheckboxBase }); } + // 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,