Skip to content

Commit 33391e0

Browse files
authored
Prevent empty div when editing comment (#12404)
* Prevent empty div when editing comment The template for attachments needs to remove whitespace and return empty when there are no attachments. Fix #10220
1 parent 8a6790b commit 33391e0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

routers/repo/issue.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,7 @@ func updateAttachments(item interface{}, files []string) error {
19751975
case *models.Comment:
19761976
attachments = content.Attachments
19771977
default:
1978-
return fmt.Errorf("Unknow Type")
1978+
return fmt.Errorf("Unknown Type: %T", content)
19791979
}
19801980
for i := 0; i < len(attachments); i++ {
19811981
if util.IsStringInSlice(attachments[i].UUID, files) {
@@ -1993,7 +1993,7 @@ func updateAttachments(item interface{}, files []string) error {
19931993
case *models.Comment:
19941994
err = content.UpdateAttachments(files)
19951995
default:
1996-
return fmt.Errorf("Unknow Type")
1996+
return fmt.Errorf("Unknown Type: %T", content)
19971997
}
19981998
if err != nil {
19991999
return err
@@ -2005,7 +2005,7 @@ func updateAttachments(item interface{}, files []string) error {
20052005
case *models.Comment:
20062006
content.Attachments, err = models.GetAttachmentsByCommentID(content.ID)
20072007
default:
2008-
return fmt.Errorf("Unknow Type")
2008+
return fmt.Errorf("Unknown Type: %T", content)
20092009
}
20102010
return err
20112011
}

templates/repo/issue/view_content/attachments.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{range .Attachments}}
1+
{{- range .Attachments -}}
22
<div class="twelve wide column" style="padding: 6px;">
33
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
44
{{if FilenameIsImage .Name}}
@@ -12,4 +12,4 @@
1212
<div class="four wide column" style="padding: 0px;">
1313
<span class="ui text grey right">{{.Size | FileSize}}</span>
1414
</div>
15-
{{end}}
15+
{{end -}}

0 commit comments

Comments
 (0)