Skip to content

Commit

Permalink
fix: use cross-browser keydown handler
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Feb 1, 2017
1 parent d1cf138 commit 67ceb9b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/dialog/dialog-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
EventEmitter,
} from '@angular/core';
import {BasePortalHost, ComponentPortal, PortalHostDirective, TemplatePortal} from '../core';
import {ESCAPE} from '../core/keyboard/keycodes';
import {MdDialogConfig} from './dialog-config';
import {MdDialogContentAlreadyAttachedError} from './dialog-errors';
import {FocusTrap} from '../core/a11y/focus-trap';
Expand Down Expand Up @@ -46,7 +47,7 @@ export type MdDialogContainerAnimationState = 'void' | 'enter' | 'exit' | 'exit-
host: {
'class': 'md-dialog-container',
'[attr.role]': 'dialogConfig?.role',
'(keydown.escape)': '_handleEscapeKey()',
'(keydown)': '_handleKeydown($event)',
'[@slideDialog]': '_state',
'(@slideDialog.done)': '_onAnimationDone($event)',
},
Expand Down Expand Up @@ -122,8 +123,8 @@ export class MdDialogContainer extends BasePortalHost implements OnDestroy {
* Handles the user pressing the Escape key.
* @docs-private
*/
_handleEscapeKey() {
if (!this.dialogConfig.disableClose) {
_handleKeydown(event: KeyboardEvent) {
if (!this.dialogConfig.disableClose && event.keyCode === ESCAPE) {
this._exit();
}
}
Expand Down

0 comments on commit 67ceb9b

Please sign in to comment.