angular / angular/components

bug(mat-button): several issues with mat-icon inside mat-button

Abierto
#26,499 1 comentario 5 reacciones 0 asignados Ver en GitHub
area: material/button 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?

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

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

14

### Description

There are several issues when you are trying to use `mat-icon` inside `mat-button`.

Issue 1.
Button layout is not consistent if we are using `ng-container`, `mat-icon` is put in `.mdc-button__label` which leads to inconsistence in how styles are applied to an icon and text near it.
Of course `ng-container` as a structural component shouldn't have influence on how button is structured.

```





```

Issue 2.
Icon placed after text is appearing before text.

```

Label


```

### Reproduction

Steps to reproduce showing all 3 issues:
[Open that stackblitz](https://stackblitz.com/edit/angular-tyswc6?file=src/app/icon-overview-example.html)

### Expected Behavior

Issue 1.
`mat-icon` or any other custom content should be either inside or outside `.mdc-button__label` no matter what structural directives are used

Issue 2.
`mat-icon` should be at the same position relative to the text as it is in code

### Actual Behavior

Issue 1.
`mat-icon` is inside `.mdc-button__label` if inside `ng-container` in code and outside - if not

Issue 2.
`mat-icon` do not preserve an order implemented in code

### Environment

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Abre la reproducción vinculada de StackBlitz y compara el comportamiento de mat-button/mat-icon en Angular Material 15.1.1, incluidos los iconos dentro de ng-container y después del texto. Se considera terminado cuando el contenido personalizado tiene una colocación coherente y mat-icon conserva el orden escrito en el template.

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