angular / angular/components

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

Ouverte
#26,499 1 commentaire 5 réactions 0 personnes assignées Voir sur GitHub
area: material/button P3
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Ouvrez la reproduction StackBlitz liée et comparez le comportement de mat-button/mat-icon dans Angular Material 15.1.1, notamment pour les icônes à l’intérieur de ng-container et après le texte. C’est terminé lorsque le contenu personnalisé est placé de manière cohérente et que mat-icon conserve l’ordre écrit dans le template.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.