angular / angular/components

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

Offen
#26,499 1 Kommentar 5 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/button P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Öffne die verlinkte StackBlitz-Reproduktion und vergleiche das Verhalten von mat-button/mat-icon in Angular Material 15.1.1, einschließlich Icons innerhalb von ng-container und nach Text. Erledigt ist die Aufgabe, wenn benutzerdefinierter Inhalt konsistent platziert wird und mat-icon die im Template angegebene Reihenfolge beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.