File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,33 @@ describe('MatTooltip', () => {
321321 expect ( tooltipDirective . _overlayRef ! . updatePosition ) . toHaveBeenCalled ( ) ;
322322 } ) ) ;
323323
324+ it ( 'should not throw when updating the position for a closed tooltip' , fakeAsync ( ( ) => {
325+ tooltipDirective . position = 'left' ;
326+ tooltipDirective . show ( 0 ) ;
327+ fixture . detectChanges ( ) ;
328+ tick ( ) ;
329+
330+ tooltipDirective . hide ( 0 ) ;
331+ fixture . detectChanges ( ) ;
332+ tick ( ) ;
333+
334+ // At this point the animation should be able to complete itself and trigger the
335+ // _animationDone function, but for unknown reasons in the test infrastructure,
336+ // this does not occur. Manually call the hook so the animation subscriptions get invoked.
337+ tooltipDirective . _tooltipInstance ! . _animationDone ( {
338+ fromState : 'visible' ,
339+ toState : 'hidden' ,
340+ totalTime : 150 ,
341+ phaseName : 'done' ,
342+ } as AnimationEvent ) ;
343+
344+ expect ( ( ) => {
345+ tooltipDirective . position = 'right' ;
346+ fixture . detectChanges ( ) ;
347+ tick ( ) ;
348+ } ) . not . toThrow ( ) ;
349+ } ) ) ;
350+
324351 it ( 'should be able to modify the tooltip message' , fakeAsync ( ( ) => {
325352 assertTooltipInstance ( tooltipDirective , false ) ;
326353
Original file line number Diff line number Diff line change @@ -120,7 +120,11 @@ export class MatTooltip implements OnDestroy {
120120
121121 if ( this . _overlayRef ) {
122122 this . _updatePosition ( ) ;
123- this . _tooltipInstance ! . show ( value , 0 ) ;
123+
124+ if ( this . _tooltipInstance ) {
125+ this . _tooltipInstance ! . show ( value , 0 ) ;
126+ }
127+
124128 this . _overlayRef . updatePosition ( ) ;
125129 }
126130 }
You can’t perform that action at this time.
0 commit comments