Pārlūkot izejas kodu

set give focus in code editor

Mitsuhiro Tanda 8 gadi atpakaļ
vecāks
revīzija
ce0de35a6c

+ 3 - 0
public/app/core/components/code_editor/code_editor.ts

@@ -110,6 +110,9 @@ function link(scope, elem, attrs) {
   elem.addClass("gf-code-editor");
   let textarea = elem.find("textarea");
   textarea.addClass('gf-form-input');
+  if (attrs.giveFocus) {
+    textarea.attr('give-focus', attrs.giveFocus);
+  }
 
   // Event handlers
   editorSession.on('change', (e) => {

+ 1 - 1
public/app/plugins/datasource/prometheus/partials/query.editor.html

@@ -2,7 +2,7 @@
 	<div class="gf-form-inline">
 		<div class="gf-form gf-form--grow">
 			<code-editor content="ctrl.target.expr" on-change="ctrl.refreshMetricData()"
-				get-completer="ctrl.getCompleter()" data-mode="prometheus">
+				get-completer="ctrl.getCompleter()" data-mode="prometheus" give-focus="ctrl.target.refId == 'A'">
 			</code-editor>
 		</div>
 	</div>