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';
1919import { Direction , Directionality } from '@angular/cdk/bidi' ;
2020import { OverlayContainer , OverlayModule , Scrollable } from '@angular/cdk/overlay' ;
2121import { 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' ;
2324import {
2425 MdTooltip ,
2526 MdTooltipModule ,
@@ -469,6 +470,13 @@ describe('MdTooltip', () => {
469470 expect ( overlayContainerElement . textContent ) . toContain ( initialTooltipMessage ) ;
470471 } ) ) ;
471472
473+ it ( 'should not throw when pressing ESCAPE' , fakeAsync ( ( ) => {
474+ expect ( ( ) => {
475+ dispatchKeyboardEvent ( buttonElement , 'keydown' , ESCAPE ) ;
476+ fixture . detectChanges ( ) ;
477+ } ) . not . toThrow ( ) ;
478+ } ) ) ;
479+
472480 } ) ;
473481
474482 describe ( 'scrollable usage' , ( ) => {
Original file line number Diff line number Diff line change @@ -270,7 +270,7 @@ export class MdTooltip implements OnDestroy {
270270
271271 /** Handles the keydown events on the host element. */
272272 _handleKeydown ( e : KeyboardEvent ) {
273- if ( this . _tooltipInstance ! . isVisible ( ) && e . keyCode === ESCAPE ) {
273+ if ( this . _isTooltipVisible ( ) && e . keyCode === ESCAPE ) {
274274 e . stopPropagation ( ) ;
275275 this . hide ( 0 ) ;
276276 }
You can’t perform that action at this time.
0 commit comments