angular / angular/components

bug(cdkTextareaAutosize): Textarea does not size to fit with initial value until window is resized

オープン
#30,652 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
area: cdk/text-field P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Auto resize of the cdkTextareaAutosize directive for a textarea, which has an initial value bound to it, is not working.

### Reproduction

It is a fork of the "Auto-resizing textarea" example of https://material.angular.io/cdk/text-field/overview. I have just added ngModel with a initial value of 5 lines. This 5 lines should be displayed without scrolling (cdkAutosizeMaxRows is also set to 5).
StackBlitz link: https://stackblitz.com/edit/oktcnmdj
Steps to reproduce:
1. Start example

### Expected Behavior

Textarea should immediatly show all 5 lines without scrollbar, without resizing the window.

### Actual Behavior

Scrollbar is shown and only 3 lines are displayed
After resizing the window it works.

### Environment

- Angular: 19.2.3
- CDK/Material: 19.2.3
- Browser(s): chrome 134.0.6998.89
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 11

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、リンクされた StackBlitz の再現を実行し、初期 ngModel 値があり、cdkAutosizeMaxRows が 5 に設定されている場合の cdkTextareaAutosize ディレクティブの動作を確認します。ウィンドウのリサイズなしですべての 5 行が表示され、スクロールバーが表示されないことを、issue に記載されている期待される動作と一致することとして確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。