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

Clear comment on successful post #20355

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/comments/js/comments.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/comments/js/comments.js.map

Large diffs are not rendered by default.

41 changes: 22 additions & 19 deletions apps/comments/src/commentstabview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
/*
/**
* Copyright (c) 2016
*
* This file is licensed under the Affero General Public License version 3
Expand Down Expand Up @@ -264,14 +264,14 @@
},

/**
* takes care of post-rendering after a new comment was added to the
* collection
*
* @param model
* @param collection
* @param options
* @private
*/
* takes care of post-rendering after a new comment was added to the
* collection
*
* @param model
* @param collection
* @param options
* @private
*/
_onAddModel: function(model, collection, options) {
// we need to render it immediately, to ensure that the right
// order of comments is kept on opening comments tab
Expand Down Expand Up @@ -303,11 +303,11 @@
},

/**
* takes care of post-rendering after a new comment was edited
*
* @param model
* @private
*/
* takes care of post-rendering after a new comment was edited
*
* @param model
* @private
*/
_onChangeModel: function(model) {
if (model.get('message').trim() === model.previous('message').trim()) {
return
Expand Down Expand Up @@ -402,9 +402,9 @@
},

/**
* Convert a message to be displayed in HTML,
* converts newlines to <br> tags.
*/
* Convert a message to be displayed in HTML,
* converts newlines to <br> tags.
*/
_formatMessage: function(message, mentions, editMode) {
message = escapeHTML(message).replace(/\n/g, '<br/>')

Expand Down Expand Up @@ -597,9 +597,12 @@
_onSubmitSuccess: function(model, $form) {
var $submit = $form.find('.submit')
var $loading = $form.find('.submitLoading')
var $message = $form.find('.message')

$submit.removeClass('hidden')
$loading.addClass('hidden')
$message.prop('contenteditable', true)
$message.text('')
},

_commentBodyHTML2Plain: function($el) {
Expand Down Expand Up @@ -651,15 +654,15 @@

message = this._commentBodyHTML2Plain($commentField)
if (commentId) {
// edit mode
// edit mode
var comment = this.collection.get(commentId)
comment.save({
message: message
}, {
success: function(model) {
self._onSubmitSuccess(model, $form)
if (model.get('message').trim() === model.previous('message').trim()) {
// model change event doesn't trigger, manually remove the row.
// model change event doesn't trigger, manually remove the row.
var $row = $form.closest('.comment')
$row.data('commentEl').removeClass('hidden')
$row.remove()
Expand Down