Commit 4b851de6 by Torkel Ödegaard

Merge branch 'prom_give_focus' of https://github.com/mtanda/grafana into mtanda-prom_give_focus

parents 1076b75a 7c566a65
...@@ -110,6 +110,16 @@ function link(scope, elem, attrs) { ...@@ -110,6 +110,16 @@ function link(scope, elem, attrs) {
elem.addClass("gf-code-editor"); elem.addClass("gf-code-editor");
let textarea = elem.find("textarea"); let textarea = elem.find("textarea");
textarea.addClass('gf-form-input'); textarea.addClass('gf-form-input');
if (scope.focus) {
setTimeout(function () {
textarea.focus();
var domEl = textarea[0];
if (domEl.setSelectionRange) {
var pos = textarea.val().length * 2;
domEl.setSelectionRange(pos, pos);
}
}, 200);
}
// Event handlers // Event handlers
editorSession.on('change', (e) => { editorSession.on('change', (e) => {
...@@ -199,6 +209,7 @@ export function codeEditorDirective() { ...@@ -199,6 +209,7 @@ export function codeEditorDirective() {
template: editorTemplate, template: editorTemplate,
scope: { scope: {
content: "=", content: "=",
focus: "=",
onChange: "&", onChange: "&",
getCompleter: "&" getCompleter: "&"
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="gf-form-inline"> <div class="gf-form-inline">
<div class="gf-form gf-form--grow"> <div class="gf-form gf-form--grow">
<code-editor content="ctrl.target.expr" on-change="ctrl.refreshMetricData()" <code-editor content="ctrl.target.expr" on-change="ctrl.refreshMetricData()"
get-completer="ctrl.getCompleter()" data-mode="prometheus"> get-completer="ctrl.getCompleter()" data-mode="prometheus" focus="ctrl.target.refId == 'A'">
</code-editor> </code-editor>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment