angular / angular/components

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

Aperta
#30,652 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
area: cdk/text-field P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia eseguendo la riproduzione collegata su StackBlitz e analizza il comportamento della direttiva cdkTextareaAutosize con un valore iniziale di ngModel e cdkAutosizeMaxRows impostato su 5. Verifica che tutte e cinque le righe vengano visualizzate senza ridimensionare la finestra e che non compaia alcuna barra di scorrimento, in linea con il comportamento previsto descritto nell'issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.