quote/reply: Leave message intact for IE/Chrome.

We had a bug where if you started typing a message
and then used quote/reply (after the fact), we
would overwrite the user's original message.

The bug was kind of subtle--the internal call
to "respond" to the message would select the message
text, and then `smart_insert` would replace the
selection, unless it was Firefox.

Note that we now also allow you to cross-post
replies, which is a plausible scenario, although
possibly unintentional at times, too.  I'm erring
on the side of giving the user control here, but
I'll add a warning in the next commit.  Our compose
fade feature should also prevent unintentional
mixes here, too.
This commit is contained in:
Steve Howell 2019-01-16 15:29:18 +00:00 committed by Tim Abbott
parent 664ee8d017
commit 01d9a3b02c
2 changed files with 26 additions and 1 deletions

View File

@ -282,6 +282,10 @@ run_test('quote_and_reply', () => {
reply_type: 'personal',
};
$('#compose-textarea').caret = (pos) => {
assert.equal(pos, 0);
};
quote_and_reply(opts);
current_msg_list.selected_message = function () {

View File

@ -389,7 +389,28 @@ exports.quote_and_reply = function (opts) {
var message_id = current_msg_list.selected_id();
var message = current_msg_list.selected_message();
if (compose_state.has_message_content()) {
// The user already started typing a message,
// so we won't re-open the compose box.
// (If you did re-open the compose box, you
// are prone to glitches where you select the
// text, plus it's a complicated codepath that
// can have other unintended consequences.)
//
// Note also that we always put the quoted text
// above the current text, which explains us
// moving the caret below. I think this is what
// most users will want, and it's consistent with
// the behavior we had on FF before this change
// (which may have been an accident of
// implementation). If we change this decision,
// we'll need to make `insert_syntax_and_focus`
// smarter about newlines.
textarea.caret(0);
} else {
exports.respond_to_message(opts);
}
compose_ui.insert_syntax_and_focus("[Quoting…]\n", textarea);
function replace_content(raw_content) {