Skip to content

bug(mat-chip): ngIf on matChipRemove breaks style #26691

Closed
@eLarocque

Description

@eLarocque

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

Hi,
When using the mat-chip with a button that has the matChipRemove directive combined with the *ngIf structural directive, as the condition changes from true / false, the mat-chip does not seem to correctly handle the state change in it's css styling.

Reproduction

Steps to reproduce:

  1. add a mat-chip in your template

  2. add a button with an matChipRemove directive and an *ngIf directive that resolves a condition
    image

  3. change the condition value so the button is removed/added to the DOM
    image

Notice that the padding of the chips does not reflect the state.

Demo: https://stackblitz.com/edit/angular-6ngj4w?file=src%2Fapp%2Fchips-overview-example.html

Expected Behavior

Should apply correct styling (ex: padding)

Actual Behavior

The text and size of the padding are broken after a structural change

Environment

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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/chips

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions