Fix no-content message not rendering after comment edit (#36733)
When non-empty comment content edited is deleted, it would render a empty comment body: <img width="355" height="85" alt="image" src="https://github.com/user-attachments/assets/3ab9d241-2668-435d-a584-afda2a5b7586" /> Fix it so it renders the same placeholder HTML that the server sends for empty content before edits: <img width="356" height="109" alt="image" src="https://github.com/user-attachments/assets/3b54ccde-f7ec-466d-a887-418f4a906d05" />
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
git_model "code.gitea.io/gitea/models/git"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
@@ -17,7 +16,6 @@ import (
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/gitrepo"
|
||||
"code.gitea.io/gitea/modules/htmlutil"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
repo_module "code.gitea.io/gitea/modules/repository"
|
||||
@@ -291,12 +289,8 @@ func UpdateCommentContent(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
if strings.TrimSpace(string(renderedContent)) == "" {
|
||||
renderedContent = htmlutil.HTMLFormat(`<span class="no-content">%s</span>`, ctx.Tr("repo.issues.no_content"))
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"content": renderedContent,
|
||||
"content": commentContentHTML(ctx, renderedContent),
|
||||
"contentVersion": comment.ContentVersion,
|
||||
"attachments": attachmentsHTML(ctx, comment.Attachments, comment.Content),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user