diff --git a/app/assets/javascripts/comments.js b/app/assets/javascripts/comments.js
index 250efc340..f2c5411ca 100644
--- a/app/assets/javascripts/comments.js
+++ b/app/assets/javascripts/comments.js
@@ -2,14 +2,11 @@
"use strict";
App.Comments = {
add_comment: function(parent_id, response_html) {
- $(response_html).insertAfter($("#js-comment-form-" + parent_id));
+ $(".comment-list:first").prepend($(response_html));
this.update_comments_count();
},
add_reply: function(parent_id, response_html) {
- if ($("#" + parent_id + " .comment-children").length === 0) {
- $("#" + parent_id).append("
");
- }
- $("#" + parent_id + " .comment-children:first").prepend($(response_html));
+ $("#" + parent_id + " .comment-list:first").prepend($(response_html));
this.update_comments_count();
},
update_comments_count: function() {
@@ -46,7 +43,7 @@
});
$("body").on("click", ".js-toggle-children", function() {
- $("#" + $(this).data().id + "_children").toggle("slow");
+ $(this).closest(".comment").find(".comment-list:first").toggle("slow");
$(this).children(".far").toggleClass("fa-minus-square fa-plus-square");
$(this).children(".js-child-toggle").toggle();
return false;
diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss
index 82aee720f..977c6fe6b 100644
--- a/app/assets/stylesheets/layout.scss
+++ b/app/assets/stylesheets/layout.scss
@@ -2084,6 +2084,7 @@ table {
}
.comment {
+ line-height: $list-lineheight;
margin: $line-height / 4 0;
position: relative;
@@ -2171,12 +2172,19 @@ table {
}
}
-.comment-children {
- border-left: 1px dashed $border;
- display: inline-block;
- margin-left: rem-calc(16);
- padding-left: rem-calc(8);
- width: 100%;
+.comment-list {
+ margin: $line-height / 4 0;
+
+ .comment-list {
+ border-left: 1px dashed $border;
+ display: inline-block;
+ padding-left: rem-calc(8);
+ width: 100%;
+ }
+
+ &:empty {
+ display: none;
+ }
}
.comment-info {
diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb
index fec693a48..443c69a01 100644
--- a/app/views/comments/_comment.html.erb
+++ b/app/views/comments/_comment.html.erb
@@ -1,7 +1,7 @@
<% valuation = local_assigns.fetch(:valuation, false) %>
<% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author] do %>
-
- <% child_comments_of(comment).each do |child| %> --
- <%= render "comments/comment", { comment: child, valuation: valuation } %>
-
- <% end %>
-
-