From c7256b2d49d294db02dcc4c318dc4b340b9f663f Mon Sep 17 00:00:00 2001 From: Karan Mistry Date: Thu, 13 Feb 2025 15:23:15 +0530 Subject: [PATCH] fix(cdk/text-field): Long multiline textfield focus issue. When we have long multiline textfield and put cursor on almost an end (For eg. on 3rd last line) the scroll moves up to the top of textarea. This fix will use `blur` and `focus` in `scrollToCaretPosition` method Fixes #20255 --- src/cdk/text-field/autosize.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cdk/text-field/autosize.ts b/src/cdk/text-field/autosize.ts index 7d17f795de54..17bcf4b044d0 100644 --- a/src/cdk/text-field/autosize.ts +++ b/src/cdk/text-field/autosize.ts @@ -367,6 +367,8 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { // it to receive focus on IE and Edge. if (!this._destroyed.isStopped && this._hasFocus) { textarea.setSelectionRange(selectionStart, selectionEnd); + textarea.blur(); + textarea.focus(); } } }