From a966546843d2a3ba62da7faee2d7e4f6f35e5fc1 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 16 Sep 2015 18:44:49 +0800 Subject: [PATCH] FIX: Cancel and reopen composer when editing first post. --- .../discourse/controllers/topic.js.es6 | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 4d8b126d026..a98323b4a22 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -207,12 +207,21 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, { return bootbox.alert(I18n.t('post.controls.edit_anonymous')); } - this.get('controllers.composer').open({ - post: post, - action: Discourse.Composer.EDIT, - draftKey: post.get('topic.draft_key'), - draftSequence: post.get('topic.draft_sequence') - }); + const composer = this.get('controllers.composer'), + composerModel = composer.get('model'), + opts = { + post: post, + action: Discourse.Composer.EDIT, + draftKey: post.get('topic.draft_key'), + draftSequence: post.get('topic.draft_sequence') + }; + + // Cancel and reopen the composer for the first post + if (composerModel && (post.get('firstPost') || composerModel.get('editingPost'))) { + composer.cancelComposer().then(() => composer.open(opts)); + } else { + composer.open(opts); + } }, toggleBookmark(post) {