Skip to content

Commit 4c69d18

Browse files
ahong11annieyw
authored andcommitted
fix(material-experimental/mdc-chips): remove icon click interaction (#22132)
Fixes an issue in the `mdc-chip` component where clicking the remove icon would select the chip before removing it. (cherry picked from commit 0003d8f)
1 parent a14c6fb commit 4c69d18

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/material-experimental/mdc-chips/chip-icons.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const _MatChipRemoveMixinBase:
173173
mdc-chip__icon mdc-chip__icon--trailing`,
174174
'[tabIndex]': 'tabIndex',
175175
'role': 'button',
176-
'(click)': 'interaction.next($event)',
176+
'(click)': '_handleClick($event)',
177177
'(keydown)': 'interaction.next($event)',
178178

179179
// We need to remove this explicitly, because it gets inherited from MatChipTrailingIcon.
@@ -196,6 +196,13 @@ export class MatChipRemove extends _MatChipRemoveMixinBase implements CanDisable
196196
}
197197
}
198198

199+
/** Emits a MouseEvent when the user clicks on the remove icon. */
200+
_handleClick(event: MouseEvent): void {
201+
this.interaction.next(event);
202+
203+
event.stopPropagation();
204+
}
205+
199206
static ngAcceptInputType_disabled: BooleanInput;
200207
static ngAcceptInputType_tabIndex: NumberInput;
201208
}

0 commit comments

Comments
 (0)