Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed same text on comment reply form #9509

Merged
merged 5 commits into from
May 17, 2021
Merged

Conversation

waridrox
Copy link
Member

@waridrox waridrox commented Apr 14, 2021

Fixes #9500 and #9508
Removed same text on first comment reply

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@waridrox waridrox requested a review from a team as a code owner April 14, 2021 22:36
@gitpod-io
Copy link

gitpod-io bot commented Apr 14, 2021

@codeclimate
Copy link

codeclimate bot commented Apr 14, 2021

Code Climate has analyzed commit 45a1ba9 and detected 0 issues on this pull request.

View more on Code Climate.

@codecov
Copy link

codecov bot commented Apr 14, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@1902557). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9509   +/-   ##
=======================================
  Coverage        ?   81.35%           
=======================================
  Files           ?       98           
  Lines           ?     5928           
  Branches        ?        0           
=======================================
  Hits            ?     4823           
  Misses          ?     1105           
  Partials        ?        0           

@RuthNjeri
Copy link
Contributor

Thanks, @waridrox, is it possible to add a test for this?

@waridrox
Copy link
Member Author

waridrox commented Apr 15, 2021

Sure, @RuthNjeri I'll add one 😄 but first I wanted to confirm if this problem persists on production env, which may then bring some modifications to the above changes. Thanks :)

@RuthNjeri
Copy link
Contributor

Alright, thanks @waridrox. I think you can test it on the stable environment first...there was a way to push directly to stable, @jywarren, is this something @waridrox can do?

@jywarren
Copy link
Member

Hi, actually you need push rights to publiclab/plots2 unstable branch, and then it publishes at http://unstable.publiclab.org/. @RuthNjeri i believe you have these privileges but if you don't get to it by tomorrow i can do it! However, we're pretty satisfied with either a system test or a manual test in GitPod, if that's easier?

Thanks!

@RuthNjeri
Copy link
Contributor

Thanks @jywarren, I pushed your changes to the unstable branch @waridrox, you can test your changes in the link Jeff shared for the stable branch

@waridrox
Copy link
Member Author

waridrox commented May 1, 2021

Thanks a lot @RuthNjeri for the help, yes the issue does solves partially on the first reply but repeats after the second reply. This has also been tested on the official website here:

unstable.mp4

So I think we need to make the changes such that the Reply to a Comment is not generated after the first reply...

@RuthNjeri
Copy link
Contributor

@waridrox, the unstable site has the changes for this PR, to understand you better, are you saying that the current changes do not fix the initial problem that was also happening on the main website?

@waridrox
Copy link
Member Author

waridrox commented May 2, 2021

@waridrox, the unstable site has the changes for this PR, to understand you better, are you saying that the current changes do not fix the initial problem that was also happening on the main website?

I'm sorry if I puzzled you 😅, but in an attempt to solve the main issue, i.e.

  1. removing reply text on the first reply to a comment, there was another issue that was observed after solving the above, i.e.
  2. After replying once on a comment, if we reply again, i.e. from the second comment onwards, the contents of the previous comment reply form are copied to a new comment reply form even if reply to a comment button is not clicked.

@@ -92,7 +92,7 @@
rows="6"
cols="40"
placeholder="<%= placeholder %>"
><%= location == :edit ? comment.comment : params[:body] %></textarea>
><%= location == :edit ? comment.comment : params[:none] %></textarea>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, i guess we need a different solution. What was the original intent of this phrase?

location == :edit ? comment.comment : params[:body]

Is it to see if the location is "edit" and if it is, display the existing comment text, but if not, to display the value of the params[:body] variable?

I wonder if it makes the assumption that the params[:body] variable is corresponding to... the submitted content of a comment, and if we should be checking to ensure it's the correct value in some other way? Remember that this may be used both on initial pageload and also in an AJAX response, which complicates this.

It could be useful to monitor the network pane of the Dev Tools to see if the partial template being sent from the server to generate this textarea is bearing the correct content?

@gitpod-io
Copy link

gitpod-io bot commented May 5, 2021

@waridrox
Copy link
Member Author

waridrox commented May 5, 2021

@jywarren @RuthNjeri, so I tried to investigate the problem further, figuring out where the data gets passed on after making a comment, and I realised that the text input field’s value was not cleared after making a POST AJAX request along with a NotyNotification! 😅. That's why the same text was repeating in the comment reply form...

So, resetting the text input field value resolved the issue:

fixed.mp4

@jywarren
Copy link
Member

jywarren commented May 5, 2021

Oh wow awesome!

Hmm, is the system test failure unrelated? Shall we restart it?

@waridrox
Copy link
Member Author

waridrox commented May 5, 2021

Oh wow awesome!

Hmm, is the system test failure unrelated? Shall we restart it?

Screenshot 2021-05-06 at 2 56 10 AM

Will take a look at this soon... Also, I think maybe these tests will have some effect if #9384 got merged due to the waiting time of the debounce function...

@waridrox
Copy link
Member Author

waridrox commented May 11, 2021

So an edge case which I forgot to thought of 😅. Clearing the contents of all text input fields meant that editing the comment was not possible with previous contents of the comment, but with the new changes it does. I'm not able to figure out though why this test is still failing 😕.
Screenshot 2021-05-12 at 1 18 49 AM

Once this is fixed, all tests will pass :)

@waridrox
Copy link
Member Author

waridrox commented May 13, 2021

Ok so finally figured out why the tests were failing, the textarea content value was getting cleared when the reply to individual comments were published. Fixed that and the tests pass now :) @jywarren pls have a look!

final-test.mp4

@waridrox waridrox requested a review from jywarren May 15, 2021 08:01
Copy link
Member

@pydevsg pydevsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work @waridrox 🎉

@RuthNjeri
Copy link
Contributor

Thanks for working on this @waridrox and great job investigating the edge cases. Would you like to write a test for this? I think it will be useful for anyone to understand what is expected of the code written. You can also set it up as another issue so that we merge this one first if you would like.

Copy link
Contributor

@RuthNjeri RuthNjeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: just a pending test.

@waridrox
Copy link
Member Author

LGTM: just a pending test.

Sure thing! 🚀

@jywarren
Copy link
Member

Awesome work. Thank you so much!!!!!!

@jywarren jywarren merged commit c4ecf7e into publiclab:main May 17, 2021
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
* Removed same text on first comment reply

* cleared textarea value

* Clear value only for the textarea

* Fixed redundant removal of content on individual reply

* Added tests to check clear input field on comment replies
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
* Removed same text on first comment reply

* cleared textarea value

* Clear value only for the textarea

* Fixed redundant removal of content on individual reply

* Added tests to check clear input field on comment replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When replying to a newly posted comment, the last comment text appears in the new "reply" comment form
4 participants