Skip to content

A platform for community discussion. Free, open, simple.

FIX: makes focust text area after complete more resilient (#9879)

Joffrey JAFFEUX253a18576913
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();
});