File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,14 @@ describe('MdTooltip', () => {
5050 tooltipDirective . _handleMouseLeave ( null ) ;
5151 expect ( overlayContainerElement . textContent ) . toBe ( '' ) ;
5252 } ) ;
53+
54+ it ( 'should be removed after parent destroyed' , ( ) => {
55+ tooltipDirective . _handleMouseEnter ( null ) ;
56+ expect ( tooltipDirective . visible ) . toBeTruthy ( ) ;
57+ fixture . destroy ( ) ;
58+ expect ( overlayContainerElement . childNodes . length ) . toBe ( 0 ) ;
59+ expect ( overlayContainerElement . textContent ) . toBe ( '' ) ;
60+ } ) ;
5361 } ) ;
5462} ) ;
5563
Original file line number Diff line number Diff line change @@ -68,6 +68,15 @@ export class MdTooltip {
6868 this . _createOverlay ( ) ;
6969 }
7070
71+ /**
72+ * Remove overlay after tooltip's parent has been destroyed
73+ */
74+ ngOnDestroy ( ) {
75+ this . visible = false ;
76+ this . _overlayRef . dispose ( ) ;
77+ this . _overlayRef = null ;
78+ }
79+
7180 /**
7281 * Create the overlay config and position strategy
7382 */
You can’t perform that action at this time.
0 commit comments