File tree 2 files changed +10
-2
lines changed 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations';
19
19
import { Direction , Directionality } from '@angular/cdk/bidi' ;
20
20
import { OverlayContainer , OverlayModule , Scrollable } from '@angular/cdk/overlay' ;
21
21
import { Platform } from '@angular/cdk/platform' ;
22
- import { dispatchFakeEvent } from '@angular/cdk/testing' ;
22
+ import { dispatchFakeEvent , dispatchKeyboardEvent } from '@angular/cdk/testing' ;
23
+ import { ESCAPE } from '@angular/cdk/keycodes' ;
23
24
import {
24
25
MdTooltip ,
25
26
MdTooltipModule ,
@@ -469,6 +470,13 @@ describe('MdTooltip', () => {
469
470
expect ( overlayContainerElement . textContent ) . toContain ( initialTooltipMessage ) ;
470
471
} ) ) ;
471
472
473
+ it ( 'should not throw when pressing ESCAPE' , fakeAsync ( ( ) => {
474
+ expect ( ( ) => {
475
+ dispatchKeyboardEvent ( buttonElement , 'keydown' , ESCAPE ) ;
476
+ fixture . detectChanges ( ) ;
477
+ } ) . not . toThrow ( ) ;
478
+ } ) ) ;
479
+
472
480
} ) ;
473
481
474
482
describe ( 'scrollable usage' , ( ) => {
Original file line number Diff line number Diff line change @@ -270,7 +270,7 @@ export class MdTooltip implements OnDestroy {
270
270
271
271
/** Handles the keydown events on the host element. */
272
272
_handleKeydown ( e : KeyboardEvent ) {
273
- if ( this . _tooltipInstance ! . isVisible ( ) && e . keyCode === ESCAPE ) {
273
+ if ( this . _isTooltipVisible ( ) && e . keyCode === ESCAPE ) {
274
274
e . stopPropagation ( ) ;
275
275
this . hide ( 0 ) ;
276
276
}
You can’t perform that action at this time.
0 commit comments