angular / angular/components

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

Aperta
#26,499 1 commento 5 reazioni 0 assegnatari Vedi su GitHub
area: material/button P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Apri la riproduzione StackBlitz collegata e confronta il comportamento di mat-button/mat-icon in Angular Material 15.1.1, incluse le icone all’interno di ng-container e dopo il testo. Il lavoro è completato quando il contenuto personalizzato ha un posizionamento coerente e mat-icon mantiene l’ordine scritto nel template.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.