Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task
VeroNemo opened this issue Dec 2, 2024 · 0 comments
Open
1 task

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

VeroNemo opened this issue Dec 2, 2024 · 0 comments
Labels
needs triage This issue needs to be triaged by the team

Comments

@VeroNemo
Copy link

VeroNemo commented Dec 2, 2024

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
    <button mat-flat-button class="ui-high-density">Some text</button>
    B. mat-icon-button
    <button mat-icon-button class="ui-high-density">Some text</button>

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.
<div class="ui-high-density">
<button mat-icon-button>
<mat-icon>home</mat-icon>
</button>
</div>

Environment

  • Angular: 18.2.11
  • CDK/Material: 18.2.13
  • Browser(s): Google Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS Sonoma
@VeroNemo VeroNemo added the needs triage This issue needs to be triaged by the team label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

1 participant