diff options
Diffstat (limited to 'app/assets/javascripts/behaviors/shortcuts/shortcuts_find_file.js')
-rw-r--r-- | app/assets/javascripts/behaviors/shortcuts/shortcuts_find_file.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/app/assets/javascripts/behaviors/shortcuts/shortcuts_find_file.js b/app/assets/javascripts/behaviors/shortcuts/shortcuts_find_file.js index 992e571e596..f26878cf161 100644 --- a/app/assets/javascripts/behaviors/shortcuts/shortcuts_find_file.js +++ b/app/assets/javascripts/behaviors/shortcuts/shortcuts_find_file.js @@ -1,4 +1,3 @@ -import Mousetrap from 'mousetrap'; import { keysFor, PROJECT_FILES_MOVE_SELECTION_UP, @@ -6,15 +5,14 @@ import { PROJECT_FILES_OPEN_SELECTION, PROJECT_FILES_GO_BACK, } from '~/behaviors/shortcuts/keybindings'; +import { addStopCallback } from '~/lib/mousetrap'; import ShortcutsNavigation from './shortcuts_navigation'; export default class ShortcutsFindFile extends ShortcutsNavigation { constructor(projectFindFile) { super(); - const oldStopCallback = Mousetrap.prototype.stopCallback; - - Mousetrap.prototype.stopCallback = function customStopCallback(e, element, combo) { + addStopCallback((e, element, combo) => { if ( element === projectFindFile.inputElement[0] && (keysFor(PROJECT_FILES_MOVE_SELECTION_UP).includes(combo) || @@ -27,12 +25,14 @@ export default class ShortcutsFindFile extends ShortcutsNavigation { return false; } - return oldStopCallback.call(this, e, element, combo); - }; + return undefined; + }); - Mousetrap.bind(keysFor(PROJECT_FILES_MOVE_SELECTION_UP), projectFindFile.selectRowUp); - Mousetrap.bind(keysFor(PROJECT_FILES_MOVE_SELECTION_DOWN), projectFindFile.selectRowDown); - Mousetrap.bind(keysFor(PROJECT_FILES_GO_BACK), projectFindFile.goToTree); - Mousetrap.bind(keysFor(PROJECT_FILES_OPEN_SELECTION), projectFindFile.goToBlob); + this.bindCommands([ + [PROJECT_FILES_MOVE_SELECTION_UP, projectFindFile.selectRowUp], + [PROJECT_FILES_MOVE_SELECTION_DOWN, projectFindFile.selectRowDown], + [PROJECT_FILES_GO_BACK, projectFindFile.goToTree], + [PROJECT_FILES_OPEN_SELECTION, projectFindFile.goToBlob], + ]); } } |