From 45a1ba92f4a4d2d47e8f545292d8047c96335bf2 Mon Sep 17 00:00:00 2001 From: waridrox Date: Thu, 15 Apr 2021 04:04:51 +0530 Subject: [PATCH 1/5] Removed same text on first comment reply --- app/views/comments/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 803918b974..ab32a674bb 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -92,7 +92,7 @@ rows="6" cols="40" placeholder="<%= placeholder %>" - ><%= location == :edit ? comment.comment : params[:body] %> + ><%= location == :edit ? comment.comment : params[:none] %>
Date: Wed, 5 May 2021 21:53:02 +0530 Subject: [PATCH 2/5] cleared textarea value --- app/views/comments/_form.html.erb | 2 +- app/views/comments/create.js.erb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index ab32a674bb..803918b974 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -92,7 +92,7 @@ rows="6" cols="40" placeholder="<%= placeholder %>" - ><%= location == :edit ? comment.comment : params[:none] %> + ><%= location == :edit ? comment.comment : params[:body] %>
Date: Wed, 12 May 2021 01:15:11 +0530 Subject: [PATCH 3/5] Clear value only for the textarea --- app/views/comments/create.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index f3ef6590cc..cec8d844af 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -41,6 +41,6 @@ fileUploadElements.forEach(function(element) { }); notyNotification('mint', 3000, 'success', 'topRight', 'Comment Added!'); $('#comment-count')[0].innerHTML = parseInt($('#comment-count')[0].innerHTML, 10)+1; -$('textarea').val(""); +$('textarea[id^="text-input-reply"]').val(""); // attach tooltips to comment buttons $('[data-toggle="tooltip"]').tooltip(); \ No newline at end of file From aa20cbc8c5d5c03d43a900c032fce95da692a3a5 Mon Sep 17 00:00:00 2001 From: waridrox Date: Fri, 14 May 2021 03:44:03 +0530 Subject: [PATCH 4/5] Fixed redundant removal of content on individual reply --- app/views/comments/create.js.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index cec8d844af..5d188a8fc2 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -28,10 +28,12 @@ let fileUploadElements = [ isButton: true } ]); + $('textarea#text-input-reply-<%= @comment.cid %>').val(""); <% else %> // new comment IS a reply to another comment // no other elements need upload functionality $('#comment-<%= @comment.reply_to %>-reply-toggle').before('<%= escape_javascript(render :partial => "notes/comment", :locals => {comment: @comment, answer_id: @answer_id}) %>') + $('textarea#text-input-reply-<%= @comment.reply_to %>').val(""); <% end %> // create image upload functionality for fresh comment's elements // see editorToolbar.js @@ -41,6 +43,5 @@ fileUploadElements.forEach(function(element) { }); notyNotification('mint', 3000, 'success', 'topRight', 'Comment Added!'); $('#comment-count')[0].innerHTML = parseInt($('#comment-count')[0].innerHTML, 10)+1; -$('textarea[id^="text-input-reply"]').val(""); // attach tooltips to comment buttons $('[data-toggle="tooltip"]').tooltip(); \ No newline at end of file From 6abf060ca7c52c710c23c363730cf654c46c79aa Mon Sep 17 00:00:00 2001 From: waridrox Date: Mon, 17 May 2021 03:22:04 +0530 Subject: [PATCH 5/5] Added tests to check clear input field on comment replies --- test/system/comment_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/system/comment_test.rb b/test/system/comment_test.rb index ce38b88e50..a6bb894d56 100644 --- a/test/system/comment_test.rb +++ b/test/system/comment_test.rb @@ -266,11 +266,22 @@ def get_path(page_type, path) end # work with just the 2nd comment reply_toggles[1].click + + # check if the comment form reply textarea has no content on input field + assert_selector("#comment-form-reply-#{comment_ids[1]} textarea.text-input", text: "") + # open the comment form by toggling, and fill in some text find("div#comment-#{comment_ids[1]}-reply-section textarea.text-input").click.fill_in with: 'H' + # open the other two comment forms reply_toggles[0].click + # check if the comment form reply textarea has no content on input field + assert_selector("#comment-form-reply-#{comment_ids[0]} textarea.text-input", text: "") + reply_toggles[2].click + # check if the comment form reply textarea has no content on input field + assert_selector("#comment-form-reply-#{comment_ids[2]} textarea.text-input", text: "") + # fill them in with text find("div#comment-#{comment_ids[0]}-reply-section textarea.text-input").click.fill_in with: 'A' find("div#comment-#{comment_ids[2]}-reply-section textarea.text-input").click.fill_in with: 'Y'