Skip to content

bug(MatButton): Extended matFab layout broken when mat-icon is behind more than one @if statement #33371

@sechel

Description

@sechel

Description

When nesting more than one @if statement around the mat-icon of an extended matFab button the layout of the button does not seem to pick up the icon anymore. Instead it seems to be part of the label and then incorrectly placed.

<section>
  <div class="example-button-row">
    <div class="example-flex-container">
      <button matFab extended>
        <mat-icon>favorite</mat-icon>
        <span>No if statement</span>
      </button>
      <button matFab extended>
        @if (true) { <mat-icon>favorite</mat-icon> }
        <span>Icon in single if statement</span>
      </button>
      <button matFab extended>
        @if (true) { @if (true) { <mat-icon>favorite</mat-icon> } }
        <span>Icon in double if statement</span>
      </button>
    </div>
  </div>
</section>
Image

Reproduction

https://stackblitz.com/edit/s1vrmxth

Environment

  • Angular: 21
  • CDK/Material: 21
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: material/buttongemini-triagedLabel noting that an issue has been triaged by geminineeds triageThis issue needs to be triaged by the team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions