angular / angular/components

bug(mat-form-field): Label for outline mat-form-field is overlapping matPrefix icon in a mat-sidenav

Abierto
#28,313 4 comentarios 3 reacciones 0 asignados Ver en GitHub
area: material/form-field area: material/sidenav 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

I noticed that the `transform` property on the `` for a `mat-form-field` with `appearance="outline"` isn't correctly picking up the width of the icon, if the form field has a `matPrefix`. This is specific to when the form field is within a `mat-sidenav` (perhaps other components that aren't visible on component init, but I haven't tried).

See attached images of the DOM elements and place in the code where this is calculated, plus attached blitz which shows the correct behavior for a `mat-form-field` with `appearance="fill"`

![image](https://github.com/angular/components/assets/15719045/d2662080-5d19-47b2-90ac-e8fe1e0b6d5e)

![image](https://github.com/angular/components/assets/15719045/ed36b6d9-234c-4205-a6cf-401ac762720c)

### Reproduction

StackBlitz link: https://stackblitz.com/edit/i6aa9z
Steps to reproduce:
1. Add a `mat-form-field` with a `matPrefix` and `appearance="outline"` to a `mat-sidenav`
2. Toggle the `mat-sidenav` open

### Expected Behavior

Label should be shifted to the left so that it does not overlap the icon

### Actual Behavior

Label is overlapping the prefix icon

### Environment

- Angular: 17.0.0
- CDK/Material: 17.0.4
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS, Windows

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con la reproducción enlazada de StackBlitz e inspecciona el cálculo de la transformación de la etiqueta outline de mat-form-field cuando el campo está inicialmente dentro de un mat-sidenav cerrado. Compara las apariencias outline y fill y, a continuación, verifica que al abrir el sidenav la etiqueta se desplaza para dejar libre el icono matPrefix.

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

Evaluación

Stack tecnológico
angular, typescript
Área
frontend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 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.