Changeset - bedccdc47bd9
[Not reviewed]
default
0 1 0
Mads Kiilerich - 8 years ago 2018-02-21 01:27:43
mads@kiilerich.com
comments: don't leave stray "Add Another Comment" buttons after cancelling adding comments on a new line

2e72d2d16a0f introduced an invisible "submitting" div above comment forms. That
div was included when counting the number of comments on a line, and it thus
broke the logic for removing the last DOM elements after cancelling comments on
a new line.

To fix that, exclude the submitting div in the selector used for counting
comments.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/public/js/base.js
Show inline comments
 
@@ -617,13 +617,13 @@ function _get_add_comment_div(target_id)
 
// An Add button is shown on non-empty forms when no form is shown.
 
// The form is controlled by show_form_opt - if undefined, form is only shown for general comments.
 
function comment_div_state($comment_div, f_path, line_no, show_form_opt) {
 
    var show_form = show_form_opt !== undefined ? show_form_opt : !f_path && !line_no;
 
    var $forms = $comment_div.children('.comment-inline-form');
 
    var $buttonrow = $comment_div.children('.add-button-row');
 
    var $comments = $comment_div.children('.comment');
 
    var $comments = $comment_div.children('.comment:not(.submitting)');
 
    $forms.remove();
 
    $buttonrow.remove();
 
    if (show_form) {
 
        _comment_div_append_form($comment_div, f_path, line_no);
 
    } else if ($comments.length) {
 
        _comment_div_append_add($comment_div, f_path, line_no);
0 comments (0 inline, 0 general)