File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 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 @@ -273,7 +273,7 @@ export class MdTooltip implements OnDestroy {
273
273
274
274
/** Handles the keydown events on the host element. */
275
275
_handleKeydown ( e : KeyboardEvent ) {
276
- if ( this . _tooltipInstance ! . isVisible ( ) && e . keyCode === ESCAPE ) {
276
+ if ( this . _isTooltipVisible ( ) && e . keyCode === ESCAPE ) {
277
277
e . stopPropagation ( ) ;
278
278
this . hide ( 0 ) ;
279
279
}
You can’t perform that action at this time.
0 commit comments