Skip to content

Commit

Permalink
fix(cdk/text-field): Long multiline textfield focus issue.
Browse files Browse the repository at this point in the history
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 angular#20255
  • Loading branch information
mistrykaran91 committed Feb 13, 2025
1 parent c40c701 commit c7256b2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cdk/text-field/autosize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

0 comments on commit c7256b2

Please sign in to comment.