@@ -213,9 +213,6 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
213213 }
214214 protected _highlighted : boolean = false ;
215215
216- /** Emitted when the user interacts with the remove icon. */
217- @Output ( ) removeIconInteraction = new EventEmitter < string > ( ) ;
218-
219216 /** Emitted when the user interacts with the chip. */
220217 @Output ( ) interaction = new EventEmitter < string > ( ) ;
221218
@@ -231,9 +228,6 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
231228 /** The unstyled chip selector for this component. */
232229 protected basicChipAttrName = 'mat-basic-chip' ;
233230
234- /** Subject that emits when the component has been destroyed. */
235- protected _destroyed = new Subject < void > ( ) ;
236-
237231 /** The chip's leading icon. */
238232 @ContentChild ( MAT_CHIP_AVATAR ) leadingIcon : MatChipAvatar ;
239233
@@ -276,17 +270,8 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
276270 // input.
277271 } ,
278272 notifyNavigation : ( ) => this . _notifyNavigation ( ) ,
279- notifyTrailingIconInteraction : ( ) =>
280- this . removeIconInteraction . emit ( this . id ) ,
281- notifyRemoval :
282- ( ) => {
283- this . removed . emit ( { chip : this } ) ;
284-
285- // When MDC removes a chip it just transitions it to `width: 0px`
286- // which means that it's still in the DOM and it's still focusable.
287- // Make it `display: none` so users can't tab into it.
288- this . _elementRef . nativeElement . style . display = 'none' ;
289- } ,
273+ notifyTrailingIconInteraction : ( ) => { } ,
274+ notifyRemoval : ( ) => this . remove ( ) ,
290275 notifyEditStart :
291276 ( ) => {
292277 this . _onEditStart ( ) ;
@@ -375,24 +360,17 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
375360
376361 ngOnDestroy ( ) {
377362 this . destroyed . emit ( { chip : this } ) ;
378- this . _destroyed . next ( ) ;
379- this . _destroyed . complete ( ) ;
380363 this . _chipFoundation . destroy ( ) ;
381364 }
382365
383366 /** Sets up the remove icon chip foundation, and subscribes to remove icon events. */
384- _initRemoveIcon ( ) {
367+ private _initRemoveIcon ( ) {
385368 if ( this . removeIcon ) {
386369 this . _chipFoundation . setShouldRemoveOnTrailingIconClick ( true ) ;
387- this . _listenToRemoveIconInteraction ( ) ;
388370 this . removeIcon . disabled = this . disabled ;
389- }
390- }
391371
392- /** Handles interaction with the remove icon. */
393- _listenToRemoveIconInteraction ( ) {
394- this . removeIcon . interaction
395- . pipe ( takeUntil ( this . _destroyed ) )
372+ this . removeIcon . interaction
373+ . pipe ( takeUntil ( this . destroyed ) )
396374 . subscribe ( event => {
397375 // The MDC chip foundation calls stopPropagation() for any trailing icon interaction
398376 // event, even ones it doesn't handle, so we want to avoid passing it keyboard events
@@ -405,7 +383,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
405383 return ;
406384 }
407385
408- this . _chipFoundation . handleTrailingActionInteraction ( ) ;
386+ this . remove ( ) ;
409387
410388 if ( isKeyboardEvent && ! hasModifierKey ( event as KeyboardEvent ) ) {
411389 const keyCode = ( event as KeyboardEvent ) . keyCode ;
@@ -416,6 +394,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
416394 }
417395 }
418396 } ) ;
397+ }
419398 }
420399
421400 /**
@@ -425,7 +404,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
425404 */
426405 remove ( ) : void {
427406 if ( this . removable ) {
428- this . _chipFoundation . beginExit ( ) ;
407+ this . removed . emit ( { chip : this } ) ;
429408 }
430409 }
431410
0 commit comments