$comment->{collapsed_reason} = $comment->author->name;
}
- if ( $comment->type != CMT_ATTACHMENT_CREATED
- && $comment->count == 0
- && length($comment->body) == 0)
- {
- $comment->{collapsed} = 1;
- $comment->{collapsed_reason} = 'empty';
- }
-
# If comment type is resolved as duplicate, do not add '...marked as duplicate...' string to comment body
if ($comment->type == CMT_DUPE_OF) {
$comment->set_type(0);
</button>
[% END %]
<button type="button" class="reply-btn minor iconic" title="Reply to this comment" aria-label="Reply"
- data-reply-id="[% comment.count FILTER none %]"
+ [% 'disabled' IF !comment.body %] data-reply-id="[% comment.count FILTER none %]"
data-reply-name="[% comment.author.name || comment.author.nick FILTER html %]">
<span class="icon" aria-hidden="true"></span>
</button>
[% comment_tag = 'pre' %]
[% END %]
- [% IF comment.body %]
+ [%# Description (Comment 0) can be empty %]
+ [% IF comment.body || comment.count == 0 %]
<[% comment_tag FILTER none %]
- class="comment-text [%= "markdown-body" IF comment.is_markdown %] [%= "bz_private" IF comment.is_private %]"
+ class="comment-text [%= "markdown-body" IF comment.is_markdown %] [%= "bz_private" IF comment.is_private %]
+ [% "empty" IF !comment.body %]"
id="ct-[% comment.count FILTER none %]" data-comment-id="[% comment.id FILTER none %]"
[% IF comment.is_markdown +%] data-ismarkdown="true" [% END ~%]
[% IF comment.collapsed +%] style="display:none"[% END ~%]>
- [%~ comment.body_full({ exclude_attachment => 1 }) FILTER renderMarkdown(bug, comment) ~%]
+ [%~ IF comment.body ~%]
+ [%~ comment.body_full({ exclude_attachment => 1 }) FILTER renderMarkdown(bug, comment) ~%]
+ [%~ ELSE ~%]
+ <em>No description provided.</em>
+ [%~ END ~%]
</[% comment_tag FILTER none %]>
[% END %]
[% END %]
#%]
[%
- RETURN IF comment.body == '';
+ RETURN UNLESS comment.body || comment.count == 0;
RETURN UNLESS user.is_insider
|| Param('edit_comments_group') && user.in_group(Param('edit_comments_group')) && comment.author.id == user.id;
RETURN UNLESS
<div class="body">
[% IF !user.is_insider && a.is_hidden %]
<div class="hidden-comment">(Hidden by Administrator)</div>
+ [% ELSIF comment.count == 0 && !a.new %]
+ <div class="empty-comment">No description provided.</div>
[% ELSE %]
<pre class="bz_comment_text">[% a.new FILTER quoteUrls(bug) %]</pre>
[% END %]
this.$edit_button.addEventListener('click', event => this.edit_button_onclick(event));
- // Check if the comment is written in Markdown
+ // Check if the comment is empty or written in Markdown
+ this.is_empty = this.$body.matches('.empty');
this.is_markdown = this.$body.matches('[data-ismarkdown="true"]');
}
// Adjust the height of `<textarea>`
this.$textarea.style.height = `${this.$textarea.scrollHeight}px`;
+ // Let the user edit Description (Comment 0) immediately if it's empty
+ if (this.is_empty) {
+ this.fetch_onload({ comments: { [this.comment_id]: '' } });
+ return;
+ }
+
// Retrieve the raw comment text
bugzilla_ajax({
url: `${BUGZILLA.config.basepath}rest/editcomments/comment/${this.comment_id}`,
/**
* Enable or disable buttons on the comment actions toolbar (not the editor's own toolbar) while editing the comment
- * to avoid any unexpected behaviour.
+ * to avoid any unexpected behaviour. The Reply button should always be disabled if the comment is empty.
* @param {Boolean} disabled Whether the buttons should be disabled.
*/
toggle_toolbar_buttons(disabled) {
- this.$change_set.querySelectorAll('.comment-actions button').forEach($button => $button.disabled = disabled);
+ this.$change_set.querySelectorAll('.comment-actions button').forEach($button => {
+ $button.disabled = $button.matches('.reply-btn') && this.is_empty ? true : disabled;
+ });
}
/**
*/
save_onsuccess(data) {
this.$body.innerHTML = data.html;
+
+ // Remove the empty state (new comment cannot be empty)
+ if (this.is_empty) {
+ this.is_empty = false;
+ this.$body.classList.remove('empty');
+ }
+
this.finish();
// Highlight code if possible
flex: none;
}
+.revision .empty-comment,
.revision .hidden-comment {
padding: 10px;
font-style: italic;
border: 1px dashed darkred;
}
+.comment-text.empty {
+ color: #666;
+}
+
/* Markdown styling adapted from https://github.com/sindresorhus/github-markdown-css */
.markdown-body {