From 99a5a49425db28ba22661fea98e008759119f5d0 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Wed, 1 Feb 2023 23:37:43 +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..f6944473f14c 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,