diff --git a/app/assets/javascripts/discourse/controllers/quote_button_controller.js b/app/assets/javascripts/discourse/controllers/quote_button_controller.js index c6e4ceb7e58..eaae6d07048 100644 --- a/app/assets/javascripts/discourse/controllers/quote_button_controller.js +++ b/app/assets/javascripts/discourse/controllers/quote_button_controller.js @@ -117,12 +117,11 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({ var buffer = this.get('buffer'); var quotedText = Discourse.Quote.build(post, buffer); + composerOpts.quote = quotedText; if (composerController.get('content.replyDirty')) { composerController.appendText(quotedText); } else { - composerController.open(composerOpts).then(function() { - composerController.appendText(quotedText); - }); + composerController.open(composerOpts); } this.set('buffer', ''); return false; diff --git a/app/assets/javascripts/discourse/models/composer.js b/app/assets/javascripts/discourse/models/composer.js index 7d5d92c46b2..289542c5de5 100644 --- a/app/assets/javascripts/discourse/models/composer.js +++ b/app/assets/javascripts/discourse/models/composer.js @@ -361,6 +361,11 @@ Discourse.Composer = Discourse.Model.extend({ loading: false }); }); + } else if (opts.action === REPLY && opts.quote) { + this.setProperties({ + reply: opts.quote, + originalText: opts.quote + }); } if (opts.title) { this.set('title', opts.title); } this.set('originalText', opts.draft ? '' : this.get('reply')); diff --git a/test/javascripts/models/composer_test.js b/test/javascripts/models/composer_test.js index 5ed17c636cd..292ace4ab98 100644 --- a/test/javascripts/models/composer_test.js +++ b/test/javascripts/models/composer_test.js @@ -204,3 +204,13 @@ test('showPreview', function() { Discourse.Mobile.mobileView = false; equal(new_composer().get('showPreview'), true, "Show preview by default in desktop view"); }); + +test('open with a quote', function() { + var quote = '[quote="neil, post:5, topic:413"]\nSimmer down you two.\n[/quote]'; + var new_composer = function() { + return Discourse.Composer.open({action: Discourse.Composer.REPLY, draftKey: 'asfd', draftSequence: 1, quote: quote}); + }; + + equal(new_composer().get('originalText'), quote, "originalText is the quote" ); + equal(new_composer().get('replyDirty'), false, "replyDirty is initally false with a quote" ); +});