angular / angular/components

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

オープン
#26,499 コメント 1 件 リアクション 5 件 担当者 0 名 GitHub で見る
area: material/button P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

リンクされた StackBlitz の再現コードを開き、Angular Material 15.1.1 における mat-button/mat-icon の動作を比較します。ng-container 内およびテキストの後にあるアイコンも含めます。カスタムコンテンツの配置が一貫し、mat-icon が template に記述された順序を維持すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。