angular / angular/components

perf(cdkTextareaAutosize): Allow custom LineHeight computation strategies

Abierto
#24,211 3 comentarios 6 reacciones 0 asignados Ver en GitHub
area: cdk/text-field G P3
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

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

_cacheTextareaLineHeight() runs at startup for every instance of cdkTextareaAutosize, despite the fact that for most applications, the line height value will be consistent and constant across the whole app, and frequently known at development time.

_cacheTextareaLineHeight() is a costly operation as it triggers css layout (measured at about 20ms per textarea in my app).

For most applications, it would be safe to compute the value only once and share between instances, and many other apps could just hardcode it.

See internal CL 421826236 for more context.

### Reproduction

Steps to reproduce:
1. Bootstrap multiple textareas with cdkTextareaAutosize

### Expected Behavior

Developer is able to override default behavior of doing costly measurements of text line height on every instance

### Actual Behavior

No mechanism to override default behavior of doing costly measurements of text line height on every instance

### Environment

- Angular: 13
- CDK/Material: 13
- Browser(s): All
- Operating System (e.g. Windows, macOS, Ubuntu): All

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start by locating cdkTextareaAutosize and its _cacheTextareaLineHeight() entry point, then trace how each instance computes and stores line height. Review any nearby tests for autosize behavior. Done means the default behavior remains covered while applications can choose a custom computation strategy that avoids unnecessary per-instance layout measurement.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend, performance
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.