Browse Source

Add explict blur behavior

Steven Silvester 8 years ago
parent
commit
75a64f8d37
2 changed files with 13 additions and 0 deletions
  1. 5 0
      src/codeeditor/editor.ts
  2. 8 0
      src/codemirror/editor.ts

+ 5 - 0
src/codeeditor/editor.ts

@@ -460,6 +460,11 @@ namespace CodeEditor {
      */
     hasFocus(): boolean;
 
+    /**
+     * Explicitly blur the editor.
+     */
+    blur(): void;
+
     /**
      * Repaint the editor.
      */

+ 8 - 0
src/codemirror/editor.ts

@@ -193,6 +193,7 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
       this.host.classList.add(READ_ONLY_CLASS);
     } else {
       this.host.classList.remove(READ_ONLY_CLASS);
+      this.blur();
     }
   }
 
@@ -297,6 +298,13 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
     return this._editor.hasFocus();
   }
 
+  /**
+   * Explicitly blur the editor.
+   */
+  blur(): void {
+    this._editor.getInputField().blur();
+  }
+
   /**
    * Repaint editor.
    */