Skip to content

Commit c1c5e00

Browse files
Prevent empty div when editing comment (#12404) (#12991)
* Prevent empty div when editing comment The template for attachments needs to remove whitespace and return empty when there are no attachments. Fix #10220 Co-authored-by: zeripath <[email protected]>
1 parent 3e279df commit c1c5e00

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
@@ -1956,7 +1956,7 @@ func updateAttachments(item interface{}, files []string) error {
19561956
case *models.Comment:
19571957
attachments = content.Attachments
19581958
default:
1959-
return fmt.Errorf("Unknow Type")
1959+
return fmt.Errorf("Unknown Type: %T", content)
19601960
}
19611961
for i := 0; i < len(attachments); i++ {
19621962
if util.IsStringInSlice(attachments[i].UUID, files) {
@@ -1974,7 +1974,7 @@ func updateAttachments(item interface{}, files []string) error {
19741974
case *models.Comment:
19751975
err = content.UpdateAttachments(files)
19761976
default:
1977-
return fmt.Errorf("Unknow Type")
1977+
return fmt.Errorf("Unknown Type: %T", content)
19781978
}
19791979
if err != nil {
19801980
return err
@@ -1986,7 +1986,7 @@ func updateAttachments(item interface{}, files []string) error {
19861986
case *models.Comment:
19871987
content.Attachments, err = models.GetAttachmentsByCommentID(content.ID)
19881988
default:
1989-
return fmt.Errorf("Unknow Type")
1989+
return fmt.Errorf("Unknown Type: %T", content)
19901990
}
19911991
return err
19921992
}

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)