Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(dialog) use keydown instead of keyup #4884

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,16 +630,16 @@ function MdDialogProvider($$interimElementProvider) {
}
};

// Add keyup listeners
element.on('keyup', keyHandlerFn);
target.on('keyup', keyHandlerFn);
// Add keydown listeners
element.on('keydown', keyHandlerFn);
target.on('keydown', keyHandlerFn);
window.on('resize', onWindowResize);

// Queue remove listeners function
removeListeners.push(function() {

element.off('keyup', keyHandlerFn);
target.off('keyup', keyHandlerFn);
element.off('keydown', keyHandlerFn);
target.off('keydown', keyHandlerFn);
window.off('resize', onWindowResize);

});
Expand Down
8 changes: 4 additions & 4 deletions src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('$mdDialog', function() {
runAnimation();

parent.triggerHandler({
type: 'keyup',
type: 'keydown',
keyCode: $mdConstant.KEY_CODE.ESCAPE
});
runAnimation();
Expand Down Expand Up @@ -405,7 +405,7 @@ describe('$mdDialog', function() {
runAnimation();

parent.triggerHandler({
type: 'keyup',
type: 'keydown',
keyCode: $mdConstant.KEY_CODE.ESCAPE
});
$timeout.flush();
Expand Down Expand Up @@ -501,7 +501,7 @@ describe('$mdDialog', function() {
expect(parent.find('md-dialog').length).toBe(1);

parent.triggerHandler({
type: 'keyup',
type: 'keydown',
keyCode: $mdConstant.KEY_CODE.ESCAPE
});
$timeout.flush();
Expand All @@ -523,7 +523,7 @@ describe('$mdDialog', function() {
runAnimation();
expect(parent.find('md-dialog').length).toBe(1);

$rootElement.triggerHandler({type: 'keyup', keyCode: $mdConstant.KEY_CODE.ESCAPE});
$rootElement.triggerHandler({type: 'keydown', keyCode: $mdConstant.KEY_CODE.ESCAPE});
runAnimation();

expect(parent.find('md-dialog').length).toBe(1);
Expand Down