From c544f78015516bc1568282ba82c858fb7a5163da Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 31 Aug 2011 11:28:48 -0700 Subject: [PATCH] When a user hits "Reply", then "Cancel" on an inline comment (without typing), don't show "Undo" Summary: When a user hits "Reply" on an inline comment, doesn't type anything, and then hits "Cancel", we incorrectly store the text of the comment the user is replying to as the "original" text, and then detect that they've changed it when they immediately cancel. Instead, store empty string as the original text. Test Plan: - Hit "Reply" and then "Cancel" on an inline comment. No undo now. - Hit "Reply", typed some text, and then hit "Cancel". Got an undo which restored my text. Reviewers: tomo, jungejason, tuomaspelkonen, aran Reviewed By: aran CC: aran, tomo Differential Revision: 879 --- src/__celerity_resource_map__.php | 40 +++++++++---------- .../behavior-edit-inline-comments.js | 9 ++++- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 2d93ef3825..f7ef9ef48a 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -451,7 +451,7 @@ celerity_register_resource_map(array( ), 'javelin-behavior-differential-edit-inline-comments' => array( - 'uri' => '/res/9d4ca5d7/rsrc/js/application/differential/behavior-edit-inline-comments.js', + 'uri' => '/res/af3bf064/rsrc/js/application/differential/behavior-edit-inline-comments.js', 'type' => 'js', 'requires' => array( @@ -1427,20 +1427,6 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/3f2092d7/differential.pkg.css', 'type' => 'css', ), - '66a154fc' => - array( - 'name' => 'differential.pkg.js', - 'symbols' => - array( - 0 => 'javelin-behavior-differential-feedback-preview', - 1 => 'javelin-behavior-differential-edit-inline-comments', - 2 => 'javelin-behavior-differential-populate', - 3 => 'javelin-behavior-differential-show-more', - 4 => 'javelin-behavior-differential-diff-radios', - ), - 'uri' => '/res/pkg/66a154fc/differential.pkg.js', - 'type' => 'js', - ), '95c67dcd' => array( 'name' => 'workflow.pkg.js', @@ -1457,6 +1443,20 @@ celerity_register_resource_map(array( 'uri' => '/res/pkg/95c67dcd/workflow.pkg.js', 'type' => 'js', ), + '982ad44b' => + array( + 'name' => 'differential.pkg.js', + 'symbols' => + array( + 0 => 'javelin-behavior-differential-feedback-preview', + 1 => 'javelin-behavior-differential-edit-inline-comments', + 2 => 'javelin-behavior-differential-populate', + 3 => 'javelin-behavior-differential-show-more', + 4 => 'javelin-behavior-differential-diff-radios', + ), + 'uri' => '/res/pkg/982ad44b/differential.pkg.js', + 'type' => 'js', + ), 'ac869011' => array( 'name' => 'typeahead.pkg.js', @@ -1521,11 +1521,11 @@ celerity_register_resource_map(array( 'javelin-behavior' => '3dbf4083', 'javelin-behavior-aphront-basic-tokenizer' => 'ac869011', 'javelin-behavior-aphront-form-disable-on-submit' => '95c67dcd', - 'javelin-behavior-differential-diff-radios' => '66a154fc', - 'javelin-behavior-differential-edit-inline-comments' => '66a154fc', - 'javelin-behavior-differential-feedback-preview' => '66a154fc', - 'javelin-behavior-differential-populate' => '66a154fc', - 'javelin-behavior-differential-show-more' => '66a154fc', + 'javelin-behavior-differential-diff-radios' => '982ad44b', + 'javelin-behavior-differential-edit-inline-comments' => '982ad44b', + 'javelin-behavior-differential-feedback-preview' => '982ad44b', + 'javelin-behavior-differential-populate' => '982ad44b', + 'javelin-behavior-differential-show-more' => '982ad44b', 'javelin-behavior-phabricator-keyboard-shortcuts' => '95c67dcd', 'javelin-behavior-workflow' => '95c67dcd', 'javelin-dom' => '3dbf4083', diff --git a/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js b/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js index aa9dc01b71..a7484da437 100644 --- a/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js +++ b/webroot/rsrc/js/application/differential/behavior-edit-inline-comments.js @@ -186,12 +186,19 @@ JX.behavior('differential-edit-inline-comments', function(config) { var node = e.getNode('differential-inline-comment'); var row = node.parentNode.parentNode; + var original = data.original; + if (op == 'reply') { + // If the user hit "reply", the original text is empty (a new reply), not + // the text of the comment they're replying to. + original = ''; + } + editor = new JX.DifferentialInlineCommentEditor(config.uri) .setTemplates(config.undo_templates) .setOperation(op) .setID(data.id) .setOnRight(data.on_right) - .setOriginalText(data.original) + .setOriginalText(original) .setRow(row) .setTable(row.parentNode) .start();