Fixes issue with preventDefault being called in timeout
This commit is contained in:
@@ -803,10 +803,14 @@ angular.module('app')
|
||||
this.altKeyObserver = keyboardManager.addKeyObserver({
|
||||
modifiers: [KeyboardManager.KeyModifierAlt],
|
||||
onKeyDown: () => {
|
||||
this.altKeyDown = true;
|
||||
$timeout(() => {
|
||||
this.altKeyDown = true;
|
||||
})
|
||||
},
|
||||
onKeyUp: () => {
|
||||
this.altKeyDown = false;
|
||||
$timeout(() => {
|
||||
this.altKeyDown = false;
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
@@ -815,7 +819,9 @@ angular.module('app')
|
||||
notElementIds: ["note-text-editor", "note-title-editor"],
|
||||
modifiers: [KeyboardManager.KeyModifierMeta],
|
||||
onKeyDown: () => {
|
||||
this.deleteNote();
|
||||
$timeout(() => {
|
||||
this.deleteNote();
|
||||
});
|
||||
},
|
||||
})
|
||||
|
||||
@@ -868,8 +874,10 @@ angular.module('app')
|
||||
editor.selectionStart = editor.selectionEnd = start + 4;
|
||||
}
|
||||
|
||||
this.note.text = editor.value;
|
||||
this.changesMade({bypassDebouncer: true});
|
||||
$timeout(() => {
|
||||
this.note.text = editor.value;
|
||||
this.changesMade({bypassDebouncer: true});
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -573,7 +573,9 @@ angular.module('app')
|
||||
modifiers: [KeyboardManager.KeyModifierMeta, KeyboardManager.KeyModifierCtrl],
|
||||
onKeyDown: (event) => {
|
||||
event.preventDefault();
|
||||
this.createNewNote();
|
||||
$timeout(() => {
|
||||
this.createNewNote();
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
class KeyboardManager {
|
||||
|
||||
constructor($timeout) {
|
||||
constructor() {
|
||||
this.observers = [];
|
||||
|
||||
this.$timeout = $timeout;
|
||||
|
||||
KeyboardManager.KeyTab = "Tab";
|
||||
KeyboardManager.KeyBackspace = "Backspace";
|
||||
|
||||
@@ -64,9 +62,7 @@ class KeyboardManager {
|
||||
if(this.eventMatchesKeyAndModifiers(event, observer.key, observer.modifiers)) {
|
||||
let callback = keyEventType == KeyboardManager.KeyEventDown ? observer.onKeyDown : observer.onKeyUp;
|
||||
if(callback) {
|
||||
this.$timeout(() => {
|
||||
callback(event);
|
||||
})
|
||||
callback(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user