From 8bcfd16f19baf379a7c8fea1652130856d5d0f40 Mon Sep 17 00:00:00 2001 From: David Robson Date: Sat, 1 Nov 2014 16:54:24 +0000 Subject: [PATCH] Editor must be focused before allowing certain keyboard shortcuts. closes #4253 - checked for the CodeMirror-focused class on the CodeMirror div - used length to determine whether CodeMirror-focused has been added - determines whether the editor has been focused on --- core/client/mixins/editor-route-base.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/client/mixins/editor-route-base.js b/core/client/mixins/editor-route-base.js index b1a2aa4e69..38c8a731ab 100644 --- a/core/client/mixins/editor-route-base.js +++ b/core/client/mixins/editor-route-base.js @@ -22,7 +22,10 @@ var EditorRouteBase = Ember.Mixin.create(styleBody, ShortcutsRoute, loadingIndic // The actual functionality is implemented in utils/codemirror-shortcuts codeMirrorShortcut: function (options) { - this.get('controller.codemirror').shortcut(options.type); + // Only fire editor shortcuts when the editor has focus. + if (Ember.$('.CodeMirror.CodeMirror-focused').length > 0) { + this.get('controller.codemirror').shortcut(options.type); + } } },