Skip to content

bug(MatFormField): mat-form-field and mat-icon with new @if @else condition #28172

@AlexKorole

Description

@AlexKorole

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

mat-icon for mat-form-field shows below mat-form-field component

Code:

 <mat-form-field class="full-width" appearance="fill">
        <mat-label translate>attributes.FILE</mat-label>
        <input
          matInput
          readonly
          [required]="!editMode"
          formControlName="FILE"
          (click)="onImageFileClick()"
          class="input-file"
        />
        @if (isFolder) {
        <mat-icon matSuffix (click)="onClickItem()" style="cursor: pointer">folder</mat-icon>
        } @else {
        <mat-icon matSuffix (click)="onDeleteItem()" style="cursor: pointer">clear</mat-icon>
        }
      </mat-form-field>

image

Reproduction

StackBlitz link:
Steps to reproduce:

  1. Create mat-form-field
  2. Add 2 mat-icons with @if @else condition
  3. Run application

Expected Behavior

mat-icon should be on the right side of mat-form-field.

image

Actual Behavior

mat-icon for mat-form-field shows below mat-form-field component.

image

Environment

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions