@@ -231,9 +231,6 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
231231 /** The unstyled chip selector for this component. */
232232 protected basicChipAttrName = 'mat-basic-chip' ;
233233
234- /** Subject that emits when the component has been destroyed. */
235- protected _destroyed = new Subject < void > ( ) ;
236-
237234 /** The chip's leading icon. */
238235 @ContentChild ( MAT_CHIP_AVATAR ) leadingIcon : MatChipAvatar ;
239236
@@ -278,15 +275,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
278275 notifyNavigation : ( ) => this . _notifyNavigation ( ) ,
279276 notifyTrailingIconInteraction : ( ) =>
280277 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- } ,
278+ notifyRemoval : ( ) => this . remove ( ) ,
290279 notifyEditStart :
291280 ( ) => {
292281 this . _onEditStart ( ) ;
@@ -375,24 +364,17 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
375364
376365 ngOnDestroy ( ) {
377366 this . destroyed . emit ( { chip : this } ) ;
378- this . _destroyed . next ( ) ;
379- this . _destroyed . complete ( ) ;
380367 this . _chipFoundation . destroy ( ) ;
381368 }
382369
383370 /** Sets up the remove icon chip foundation, and subscribes to remove icon events. */
384- _initRemoveIcon ( ) {
371+ private _initRemoveIcon ( ) {
385372 if ( this . removeIcon ) {
386373 this . _chipFoundation . setShouldRemoveOnTrailingIconClick ( true ) ;
387- this . _listenToRemoveIconInteraction ( ) ;
388374 this . removeIcon . disabled = this . disabled ;
389- }
390- }
391375
392- /** Handles interaction with the remove icon. */
393- _listenToRemoveIconInteraction ( ) {
394- this . removeIcon . interaction
395- . pipe ( takeUntil ( this . _destroyed ) )
376+ this . removeIcon . interaction
377+ . pipe ( takeUntil ( this . destroyed ) )
396378 . subscribe ( event => {
397379 // The MDC chip foundation calls stopPropagation() for any trailing icon interaction
398380 // event, even ones it doesn't handle, so we want to avoid passing it keyboard events
@@ -405,7 +387,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
405387 return ;
406388 }
407389
408- this . _chipFoundation . handleTrailingActionInteraction ( ) ;
390+ this . remove ( ) ;
409391
410392 if ( isKeyboardEvent && ! hasModifierKey ( event as KeyboardEvent ) ) {
411393 const keyCode = ( event as KeyboardEvent ) . keyCode ;
@@ -416,6 +398,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
416398 }
417399 }
418400 } ) ;
401+ }
419402 }
420403
421404 /**
@@ -425,7 +408,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
425408 */
426409 remove ( ) : void {
427410 if ( this . removable ) {
428- this . _chipFoundation . beginExit ( ) ;
411+ this . removed . emit ( { chip : this } ) ;
429412 }
430413 }
431414
0 commit comments