Explorar o código

copy from give-focus

Mitsuhiro Tanda %!s(int64=8) %!d(string=hai) anos
pai
achega
d971eddc7a
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      public/app/core/components/code_editor/code_editor.ts

+ 8 - 1
public/app/core/components/code_editor/code_editor.ts

@@ -111,7 +111,14 @@ function link(scope, elem, attrs) {
   let textarea = elem.find("textarea");
   let textarea = elem.find("textarea");
   textarea.addClass('gf-form-input');
   textarea.addClass('gf-form-input');
   if (attrs.giveFocus) {
   if (attrs.giveFocus) {
-    textarea.attr('give-focus', attrs.giveFocus);
+    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