-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Added animation to save icon when user enters a comment text #9384
Conversation
Codecov Report
@@ Coverage Diff @@
## main #9384 +/- ##
=======================================
Coverage ? 81.35%
=======================================
Files ? 98
Lines ? 5928
Branches ? 0
=======================================
Hits ? 4823
Misses ? 1105
Partials ? 0 |
@waridrox Thanks so much for this, will give a detailed review and feedback later today, but honestly it looks pretty good. One thing to note is that the save & recover system test needs to be updated (that's what's failing right now). |
Oh!😅 Will take a look at this soon... |
@waridrox Yeah, that's a good idea! Updating the test isn't necessarily your responsibility (I wrote it), but I still recommend taking a look. I'm thinking the test probably needs to be updated to wait for the debouncing to occur before it refreshes the page. I think it will be a relatively easy fix. |
My apologies, got a little busy lately 😅, @noi5e can you point me to the right file to implement the tests for debounce function. Further researching upon, I came across the |
Just when I though about adding tests, I realised we missed an edge case wherein due to the similar functional elements like the toolbar and the image upload section, the current changes also reflect if a edge-case.mp4 |
let comment_temp_id = (document.activeElement.parentElement.parentElement.id); | ||
let imager_bar = (document.activeElement.nextElementSibling.className); | ||
|
||
$('#'+comment_temp_id).find('.btn-toolbar').find(".save-button").find("i").removeClass("fa fa-save").addClass("fas fa-sync fa-spin"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
app/assets/javascripts/editor.js
Outdated
|
||
//adding delay and revering the styles | ||
setTimeout(() => { | ||
$("#comment-form-main .btn-toolbar #save-button-main").find("i").removeClass("fas fa-sync fa-spin").addClass("fa fa-save");; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary semicolon.
Here's the fix for the edge case: reason being that each comment has its own unique id associated so earlier code was targeting all ids instead of the specific one that the user is currently making changes on. edge.case.fix.mp4Now working on testing... |
$E.save($E); | ||
}) | ||
//preventing multiple clicks on the button | ||
if(!e.detail || e.detail == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected '===' and instead saw '=='.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't ===
supposed to check type as well 🤔. I think here ==
should suffice. But e.detail
returns a typeof = number
so I think we can use ===
here.
The tests for save and recover button have been updated to account for debounce function and they pass now :) @noi5e @RuthNjeri Kindly review this. Thanks :) |
Hi @waridrox, what do you think about the other comments made by CodeClimate? Do you think you can address them? I see you responded to one...would you like to address the rest? We usually don't implement everything suggested by CodeClimate depending on the trade offs. |
Yes, @RuthNjeri, I've looked at the comments by CodeClimate, most of them being a repetition of one another 😅. But I don't see any problem in the issues that it is suggesting to be fixed -
|
@RuthNjeri @noi5e @jywarren pls review the changes. Thanks :) |
Sorry the tests did not run and instead failed... |
Refactor the code @waridrox. |
If you'd like we can bypass the code climate suggestions! They are only suggestions but if you'd like to address any of them we can also wait, no rush! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @waridrox, it looks good to me, I think one more reviewer should approve this(@jywarren or @cesswairimu)...then it will be okay to merge 🚀
f1b318a
to
338859f
Compare
After syncing the branch with upstream, unit tests seem to be failing...🤔 |
Aha - for some reason i also saw this on #9665 (comment) and suggested a fix there - adding a sort to the test or to the main codebase, as i believe it's an ordering issue that can happen sometimes if we don't explicitly send a sort to the database. If you're able to open a new PR then possibly this and #9665 (comment) can both be rebased over it once we resolve that. In the meantime, i'll restart the test to see if we get past it that way. Thanks! |
Ok sorry @waridrox but now the unit tests upstream are fixed and just one more rebase should work. Many thanks for your patience!!! |
e58228f
to
320ff86
Compare
Code Climate has analyzed commit 320ff86 and detected 5 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
@jywarren Done! |
OK, merging now, and many thanks!!! Regarding the revert button, i wonder if we should have saving add the text to an array of recent texts that have been saved. Then revert could just cycle back through that list. |
@waridrox @noi5e we could break out that idea of the array of comments saves into a new issue too! I think we'd have to be careful to flush the list... maybe only save 5 or 10 states, and/or delete much older ones or something? For example, what if someone types in something private, it saves, and they change their mind before posting it, they log out, someone else logs in, and they are able to recover the text. |
i.e. we could make it auto-delete texts older than an hour to mitigate this risk maybe. |
I know @waridrox is now working on other projects, though! So perhaps someone else from the @publiclab/soc team would be interested in taking this idea of fixing the comment revert button up? |
…ab#9384) * Added animation to save icon when user enters a comment text * Edge case handled * Updated tests for save and recover buttons * Update editorToolbar.js * Unnecessary semicolon * ESLint typeof operator * let instead of var * Matched padding of saving text with file upload text
…ab#9384) * Added animation to save icon when user enters a comment text * Edge case handled * Updated tests for save and recover buttons * Update editorToolbar.js * Unnecessary semicolon * ESLint typeof operator * let instead of var * Matched padding of saving text with file upload text
Fixes #9362
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
rake test
@publiclab/reviewers
for help, in a comment belowFinal working version -
Final.mp4
I've removed the
console.log
statements 😄.@noi5e kindly review this. Thanks :)