From f8ea48f1fe6362696ed30e01030e75c117ce4323 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Mon, 30 May 2022 10:50:16 +0200 Subject: [PATCH] fix: Removed focussing after timeout in text input (#4716) * fix: Removed focussing after timeout in text input * Added timeout in mouse handler * Added new line --- lib/ace/editor.js | 8 -------- lib/ace/mouse/mouse_handler.js | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 740b0477784..2c00672d240 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -692,14 +692,6 @@ Editor.$uid = 0; * Brings the current `textInput` into focus. **/ this.focus = function() { - // focusing after timeout is not needed now, but some code using ace - // depends on being able to call focus when textarea is not visible, - // so to keep backwards compatibility we keep this until the next major release - var _self = this; - setTimeout(function() { - if (!_self.isFocused()) - _self.textInput.focus(); - }); this.textInput.focus(); }; diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js index 22912d7706a..9f4e2f4ea2c 100644 --- a/lib/ace/mouse/mouse_handler.js +++ b/lib/ace/mouse/mouse_handler.js @@ -56,6 +56,10 @@ var MouseHandler = function(editor) { if (windowBlurred) window.focus(); editor.focus(); + // Without this editor is blurred after double click + setTimeout(function () { + if (!editor.isFocused()) editor.focus(); + }); }; var mouseTarget = editor.renderer.getMouseEventTarget();