From 1bb0fd9eb605cdb4dd42d39b668af49418787b8f Mon Sep 17 00:00:00 2001 From: Chandrasekhar Ramakrishnan Date: Sat, 13 Jul 2019 11:43:28 -0500 Subject: [PATCH] wip: work on #3484 -- removing focus on esc. --- packages/console/src/widget.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/console/src/widget.ts b/packages/console/src/widget.ts index f3d610711074..5cf010f0bb67 100644 --- a/packages/console/src/widget.ts +++ b/packages/console/src/widget.ts @@ -613,6 +613,23 @@ export class CodeConsole extends Widget { if (event.keyCode === 13 && !editor.hasFocus()) { event.preventDefault(); editor.focus(); + } else if (event.keyCode === 27 && editor.hasFocus()) { + // Set to command mode; + event.preventDefault(); + editor.blur(); + // TODO Need to figure out what needs to happen for keyboard shortcuts to work + // this._content.node.focus(); + // this._content.widgets[0].node.focus() + // this._banner.node.focus(); + // this._banner.activate(); + // console.log(this._banner.node); + + // Hack to prevent CodeMirror from resetting focus on this widget + let codeMirror: any = (editor as any)['_editor']; + codeMirror.options.readOnly = 'nocursor'; + window.setTimeout(() => { + codeMirror.options.readOnly = false; + }, 100); } }