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 Jan 13, 2025
1 parent 3bb9338 commit a6c08d5
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 @@ -358,6 +358,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 a6c08d5

Please sign in to comment.