From 2953d64429fa20fa4dd36195543629ea85b3c78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 8 Sep 2017 11:43:29 +0200 Subject: [PATCH] prometheus: minor update to focus editor PR, #9201 --- public/app/core/components/code_editor/code_editor.ts | 7 ++++--- public/app/features/panel/query_ctrl.ts | 2 ++ .../datasource/prometheus/partials/query.editor.html | 2 +- public/sass/components/_code_editor.scss | 4 ++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/public/app/core/components/code_editor/code_editor.ts b/public/app/core/components/code_editor/code_editor.ts index 0ceb21d0335..7c41eb3b3a2 100644 --- a/public/app/core/components/code_editor/code_editor.ts +++ b/public/app/core/components/code_editor/code_editor.ts @@ -110,7 +110,8 @@ function link(scope, elem, attrs) { elem.addClass("gf-code-editor"); let textarea = elem.find("textarea"); textarea.addClass('gf-form-input'); - if (scope.focus) { + + if (scope.codeEditorFocus) { setTimeout(function () { textarea.focus(); var domEl = textarea[0]; @@ -118,7 +119,7 @@ function link(scope, elem, attrs) { var pos = textarea.val().length * 2; domEl.setSelectionRange(pos, pos); } - }, 200); + }, 100); } // Event handlers @@ -209,7 +210,7 @@ export function codeEditorDirective() { template: editorTemplate, scope: { content: "=", - focus: "=", + codeEditorFocus: "<", onChange: "&", getCompleter: "&" }, diff --git a/public/app/features/panel/query_ctrl.ts b/public/app/features/panel/query_ctrl.ts index 67f4f93d16c..148322360bc 100644 --- a/public/app/features/panel/query_ctrl.ts +++ b/public/app/features/panel/query_ctrl.ts @@ -10,9 +10,11 @@ export class QueryCtrl { panel: any; hasRawMode: boolean; error: string; + isLastQuery: boolean; constructor(public $scope, private $injector) { this.panel = this.panelCtrl.panel; + this.isLastQuery = _.indexOf(this.panel.targets, this.target) === (this.panel.targets.length - 1); } refresh() { diff --git a/public/app/plugins/datasource/prometheus/partials/query.editor.html b/public/app/plugins/datasource/prometheus/partials/query.editor.html index d35f9f9c14c..a34a752bd95 100644 --- a/public/app/plugins/datasource/prometheus/partials/query.editor.html +++ b/public/app/plugins/datasource/prometheus/partials/query.editor.html @@ -2,7 +2,7 @@
+ get-completer="ctrl.getCompleter()" data-mode="prometheus" code-editor-focus="ctrl.isLastQuery">
diff --git a/public/sass/components/_code_editor.scss b/public/sass/components/_code_editor.scss index 0f03e686546..4a13d4aa811 100644 --- a/public/sass/components/_code_editor.scss +++ b/public/sass/components/_code_editor.scss @@ -77,3 +77,7 @@ $doc-font-size: $font-size-sm; .ace_tooltip { border-radius: 3px; } + +.ace_hidden-cursors .ace_cursor { + opacity: 0 !important; +}