angular / angular/components

bug(COMPONENT): mat-icon-button needs to be wrapped to apply density

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

説明

### Is this a regression?

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

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

_No response_

### Description

When applying custom density (via a custom CSS class) using Angular Material Theme API directly to Angular Material button (e.g., mat-flat-button, mat-stroked-button), the height is adjusted as expected. However, when the custom density context (the same CSS class as for mat-stroked-button etc) is applied directly to a button mat-icon-button, the size of it remains unchanged. The density changes are only applied if the mat-icon-button is wrapped in an element with the density class.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/sb1-41rfph?file=src%2Fapp%2Fapp.component.scss
StackOverflow link: https://stackoverflow.com/questions/79227144/mat-icon-button-needs-to-be-wrapped-to-apply-density

Steps to reproduce:
1. Create css class:
`.ui-high-density {
@include mat.icon-button-density(-2);
}`

2. Apply css class .ui-high-density to button:
A. mat-flat-button
`Some text`
B. mat-icon-button
`Some text`

### Expected Behavior

The size of height on both, mat-flat-button and mat-icon-button, will change.

### Actual Behavior

The height change only on mat-flat-button and mat-icon-button stay the same.

When I wrapped mat-icon-button into div with class ui-hight-density, the height of button changed.
`

`
` `
` home`
` `
`
`

### Environment

- Angular: 18.2.11
- CDK/Material: 18.2.13
- Browser(s): Google Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS Sonoma

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

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

調査の方向性

src/app/app.component.scss の StackBlitz reproduction と、issue で説明されている mat.icon-button-density(-2) mixin から始めます。density が mat-flat-button に直接適用される場合と、mat-icon-button の直接的なケースを比較し、その後、wrapper なしで icon button のサイズが変わること、および reproduction が期待される動作と一致することを確認します。

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

評価

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

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

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