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', () => {
321
321
expect ( tooltipDirective . _overlayRef ! . updatePosition ) . toHaveBeenCalled ( ) ;
322
322
} ) ) ;
323
323
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
+
324
351
it ( 'should be able to modify the tooltip message' , fakeAsync ( ( ) => {
325
352
assertTooltipInstance ( tooltipDirective , false ) ;
326
353
Original file line number Diff line number Diff line change @@ -120,7 +120,11 @@ export class MatTooltip implements OnDestroy {
120
120
121
121
if ( this . _overlayRef ) {
122
122
this . _updatePosition ( ) ;
123
- this . _tooltipInstance ! . show ( value , 0 ) ;
123
+
124
+ if ( this . _tooltipInstance ) {
125
+ this . _tooltipInstance ! . show ( value , 0 ) ;
126
+ }
127
+
124
128
this . _overlayRef . updatePosition ( ) ;
125
129
}
126
130
}
You can’t perform that action at this time.
0 commit comments