Problem/Motivation
When a comment is edited and saved the user gets a status message that reads: 'Your comment has been posted.'
That is confusing because it suggests that a new comment has been created.
Proposed resolution
Use a status message like 'The comment has been updated.' on comment edit.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | Screen Recording After.mov | 23.16 MB | rinku jacob 13 |
| #20 | Screen Recording Before.mov | 16.29 MB | rinku jacob 13 |
| #18 | 3346218-after-patch.png | 184.33 KB | nayana_mvr |
| #18 | 3346218-before-patch.png | 169.42 KB | nayana_mvr |
Issue fork drupal-3346218
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3346218-d11-fix-comment-update-message
changes, plain diff MR !4845
- 3346218-
changes, plain diff MR !3982
- 3346218-harlor
changes, plain diff MR !4834
- 3346218--patch-b83b
compare
- 10.1.x
compare
- 10.0.x
changes, plain diff MR !3603
- 3346218-status-message-on
changes, plain diff MR !3631
Comments
Comment #3
urvashi_vora commentedHi,
From the issue, I came to know that the message "Your comment has been posted" arrives from
/core/modules/comment/src/CommentForm.php line number 396
$this->messenger()->addStatus($this->t('Your comment has been posted.'));Other than that, there are two more files which contains the same message but when I edited comment in my backend and did several tests, always the results landed me on CommentForm.php file.
Also, when we add a new comment or we edit an existing comment, always the message comes from the same file.
Thanks.
Comment #4
harlor commentedYeah exactly - do you think this is reasonable?
Because I think we should change this.
Comment #5
urvashi_vora commentedIndeed, I agree.
We should change this so that the user may be notified with the difference of "Posted" and "Updated"
Comment #6
harlor commentedThe NodeForm.php uses a simple if clause for that:
I guess in the CommentForm we could do the same.
Comment #7
urvashi_vora commentedI believe, this will be a valid approach to meet the requirement.
Comment #10
urvashi_vora commentedThe MR changes looks good to me, but further I would definitely like to test it thoroughly in different setups before moving it to RTBC.
At present, setting the issue status as "Needs Review".
Thanks @Kaushik1216 for the work.
I appreciate your efforts.
Comment #11
harlor commented@Kaushik1216, Look at the tests ;)
Also I'd expect that we have to adjust this test:
Comment #12
Kaushik1216 commented@Harlor please more elaborate your comment #11 on adjust test . ie where and why we should add this code as I am new here .Thanks in advance !
Comment #13
harlor commented@Kaushik1216,
If you haven't already make your self familiar with automated testing in drupal. You can find the error I expected to happen in #11 now in https://www.drupal.org/pift-ci-job/2611730.
Comment #16
Kaushik1216 commented@ Harlor Please help me to add test for this merge request
Comment #17
harlor commented@Kaushik1216, Ah the two messages just needed to be interchanged so some of the failing tests were actually right ;)
Comment #18
nayana_mvr commentedVerified the MR!3603 on Drupal version 10.1.x. The patch applied cleanly and now the status message on comment edit is changed to 'Your comment has been updated.' I have added the before and after screenshots for reference. Need RTBC+1.
Comment #19
rinku jacob 13 commentedReviewed Merge requests!3603 . After applying the Merge request edit comment message changed to "Your comment has been updated". Need RTBC +1.
Comment #20
rinku jacob 13 commentedComment #21
Kaushik1216 commented@Harlor Thanks for changing MR . A warm Thanks to @nayana_mvr and Rinku Jacob 13 for testing MR
Comment #22
larowlanThanks folks! left some comments on the MR - tl;dr I think this is close, I'd just like to see the message derivation in it's own method to avoid the complexity of if/else/elseif and we need to target 10.1.x because of the string change.
Comment #26
harlor commentedI'm a bit confused with the branches on which one are we working now?
Comment #27
Kaushik1216 commentedI am working previously on 10.1 branch but now somehow branch for this issue changed to 11.0.x
Comment #29
harlor commentedI couldn't figure out how the branch could be fixed so I created a new branch from 10.1.x and cherry-picked the relevant commits...
I also added the doc-block for the getStatusMessage method
Comment #30
smustgrave commentedChange looks good. Believe @larowlan did a review but branch will have to be updated to 11.x please
Comment #32
harlor commentedDone
Comment #33
harlor commentedCan we rerun the Jenkins pipeline?
Comment #34
smustgrave commentedYup, as long as the MR still applies you can click "Add test/retest" underneath it.
Reran for 11.x and all green and confirmed the new message.
Comment #35
xjmCan we please close all the MRs except the correct one?
Also, we don't tag string changes anymore.
Thanks!
Comment #37
harlor commentedSorry, I closed my obsolete MR.
@Kaushik1216 Could you please close https://git.drupalcode.org/project/drupal/-/merge_requests/3982? It seems that I don't have the permission to do that.
Comment #39
Kaushik1216 commenteddone!
Comment #40
harlor commentedThx!
Back to RTBC
Comment #41
xjmPosted a couple minor suggestions on the MR. Thanks!
Comment #43
harlor commentedI committed the changes as suggested ;)
Comment #47
smustgrave commentedMR appears to have failures 4845
Comment #48
harlor commentedI merged 11.x into the MR's branch - and the tests succeeded.
Comment #49
smustgrave commentedFeedback appears to have been addressed.
Comment #50
catch@xjm's feedback on the MR hasn't been addressed - suggestion was to make $is_new the second parameter. Also I'm not sure we need that parameter at all, since $comment->isNew() should work?
Comment #52
harlor commented@catch, @pradhumanjain2311, We need the $is_new variable because the status message is generated after $comment->save(); and the comment is no longer new.
Sorry, I forgot to interchange the parameters :S
Comment #53
harlor commentedI reverted to the variant with two parameters and interchanged the parameters.
Comment #54
smustgrave commentedSorry for jumping the gun in #49 but seeing $is_new as the 2nd parameter now
Comment #55
larowlanLeft a minor comment on the MR
Comment #56
harlor commentedI applied the suggested changes - this time using gitlab :D
Comment #57
smustgrave commentedFeedback appears to be addressed.
Comment #58
xjmSaving issue credits. I granted credit for the manual testing in #20 as well as that in #18, because in this scenario (where the original message is correct sometimes, and the new message is correct others), the video is actually really helpful over screenshots. (Normally we would not grant credit for duplicate manual testing.)
Comment #59
xjmThis looks great now. I added a dockblock explanation of
$is_new, since @catch's question was a totally sensible one.Comment #62
xjmCommitted to 11.x and cherry-picked to 10.3.x. I did not backport it to 10.2.x as it includes a string addition and slight behavior change. Thanks!
Comment #63
xjm