Skip to content

bug(matChipRemove): matChipRemove does not preventDefault() #24436

Closed
@max-vogler

Description

@max-vogler

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

matChipRemove does not preventDefault(), allowing standard click behavior like following a parent hyperlink to trigger. matChipRemove does stopPropagation() though.

Reproduction

Steps to reproduce: https://stackblitz.com/edit/components-issue-va7p6c?file=src%2Fapp%2Fexample-component.html

<mat-chip-list>
  <a href="https://example.org">
    <mat-chip>example.org <mat-icon matChipRemove>close</mat-icon></mat-chip>
  </a>
</mat-chip-list>

Expected Behavior

Clicking on matChipRemove should fully consume the event, including preventDefault().

Actual Behavior

Clicking on matChipRemove triggers the parent hyperlink.

Environment

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

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functionsarea: material/chips

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions