From 253a185769130630eb80e6c36d08aca37a848037 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 26 May 2020 16:27:02 +0200 Subject: [PATCH] FIX: makes focust text area after complete more resilient (#9879) --- .../javascripts/discourse/app/components/d-editor.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js index 4fd5ec4bc23..bfdf021bff9 100644 --- a/app/assets/javascripts/discourse/app/components/d-editor.js +++ b/app/assets/javascripts/discourse/app/components/d-editor.js @@ -898,8 +898,16 @@ export default Component.extend({ // ensures textarea scroll position is correct _focusTextArea() { - const textarea = this.element.querySelector("textarea.d-editor-input"); schedule("afterRender", () => { + if (!this.element || this.isDestroying || this.isDestroyed) { + return; + } + + const textarea = this.element.querySelector("textarea.d-editor-input"); + if (!textarea) { + return; + } + textarea.blur(); textarea.focus(); });