diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js index f3d7437056b..e3a54104609 100644 --- a/src/components/dialog/dialog.js +++ b/src/components/dialog/dialog.js @@ -707,10 +707,10 @@ function MdDialogProvider($$interimElementProvider) { captureParentAndFromToElements(options); configureAria(dialogElement, options); showBackdrop(scope, element, options); + activateListeners(element, options); return dialogPopIn(element, options) .then(function() { - activateListeners(element, options); lockScreenReader(element, options); warnDeprecatedActions(); focusOnOpen(); diff --git a/src/components/dialog/dialog.spec.js b/src/components/dialog/dialog.spec.js index 29ca1a7e4c0..36f2e1e46a4 100644 --- a/src/components/dialog/dialog.spec.js +++ b/src/components/dialog/dialog.spec.js @@ -979,6 +979,31 @@ describe('$mdDialog', function() { expect(parent.find('md-dialog').length).toBe(0); })); + it('should close on escape before the animation started', + inject(function($mdDialog, $rootScope, $rootElement, $timeout, $animate, $mdConstant) { + var parent = angular.element('