Skip to content

Commit

Permalink
fix(material-experimental/mdc-chips): remove icon click interaction (#…
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
ahong11 authored and annieyw committed Mar 9, 2021
1 parent a14c6fb commit 4c69d18
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/material-experimental/mdc-chips/chip-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const _MatChipRemoveMixinBase:
mdc-chip__icon mdc-chip__icon--trailing`,
'[tabIndex]': 'tabIndex',
'role': 'button',
'(click)': 'interaction.next($event)',
'(click)': '_handleClick($event)',
'(keydown)': 'interaction.next($event)',

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

/** Emits a MouseEvent when the user clicks on the remove icon. */
_handleClick(event: MouseEvent): void {
this.interaction.next(event);

event.stopPropagation();
}

static ngAcceptInputType_disabled: BooleanInput;
static ngAcceptInputType_tabIndex: NumberInput;
}

0 comments on commit 4c69d18

Please sign in to comment.