From 8c48c124984e986715d9e20b5808b6f76da4aebb Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 27 Nov 2015 13:31:52 -0500 Subject: [PATCH] FIX: Inserting link wouldn't clear the text field sometimes --- .../javascripts/discourse/components/d-editor-modal.js.es6 | 2 ++ app/assets/javascripts/discourse/components/d-editor.js.es6 | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/d-editor-modal.js.es6 b/app/assets/javascripts/discourse/components/d-editor-modal.js.es6 index fc2206b8321..1b2ff96d780 100644 --- a/app/assets/javascripts/discourse/components/d-editor-modal.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor-modal.js.es6 @@ -29,9 +29,11 @@ export default Ember.Component.extend({ if (key.keyCode === 27) { this.send('cancel'); + return false; } if (key.keyCode === 13) { this.send('ok'); + return false; } }); }, diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index 8c71ad9de7e..f96eac84b52 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -412,7 +412,7 @@ export default Ember.Component.extend({ const insert = `${sel.pre}${text}`; this.set('value', `${insert}${sel.post}`); this._selectText(insert.length, 0); - Ember.run.once("afterRender", () => { $("textarea.d-editor-input").focus(); } ); + Ember.run.scheduleOnce("afterRender", () => this.$("textarea.d-editor-input").focus()); }, actions: {