Edit comment bug: can not save empty comment #12701

Closed
opened 2025-11-02 10:18:29 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @yp05327 on GitHub (Mar 22, 2024).

Description

  1. can not save empty comment
    I think we need to check oldContent == comment.Content instead of len(comment.Content) == 0
    and return an empty json, then check data.content === undefined in js.
    image

(the second one has been fixed)

  1. edit comment regression

Caused by #29843
after the edition you will see this strange code:
image
If I revert the changes from #29843, it works
Have no idea how to fix this, as lint not allow using append.
maybe other changes in #29843 will also have this issue?
the appended data will be text not DOM element.
image

Gitea Version

latest

Originally created by @yp05327 on GitHub (Mar 22, 2024). ### Description 1. can not save empty comment I think we need to check `oldContent == comment.Content` instead of `len(comment.Content) == 0` and return an empty json, then check `data.content === undefined` in js. ![image](https://github.com/go-gitea/gitea/assets/18380374/4a00cabb-38a4-4848-9058-0ecbba2c6d7e) ---- (the second one has been fixed) 2. edit comment regression <details> Caused by [#29843](https://github.com/go-gitea/gitea/pull/29843/files#diff-4f89ee029f289a1c40cf85fa40b0a10046a93d5fe1dac8d158e98bebd2e6e49eR439) after the edition you will see this strange code: ![image](https://github.com/go-gitea/gitea/assets/18380374/6abbbb1a-6bd9-4385-ba66-c9826b6470e9) If I revert the changes from #29843, it works Have no idea how to fix this, as lint not allow using append. maybe other changes in #29843 will also have this issue? the appended data will be text not DOM element. ![image](https://github.com/go-gitea/gitea/assets/18380374/5711b935-1f65-4112-8c39-5bd3460c30ec) </details> ### Gitea Version latest
GiteaMirror added the type/bug label 2025-11-02 10:18:29 -06:00
Author
Owner

@yardenshoham commented on GitHub (Mar 22, 2024):

@yardenshoham commented on GitHub (Mar 22, 2024): - https://github.com/go-gitea/gitea/pull/29991 fixes the bug caused by https://github.com/go-gitea/gitea/pull/29843
Author
Owner

@yardenshoham commented on GitHub (Mar 22, 2024):

@wxiaoguang should we remove https://github.com/go-gitea/gitea/labels/issue%2Fcritical now?

@yardenshoham commented on GitHub (Mar 22, 2024): @wxiaoguang should we remove https://github.com/go-gitea/gitea/labels/issue%2Fcritical now?
Author
Owner

@wxiaoguang commented on GitHub (Mar 22, 2024):

Oh yes, I just added it for remembering (to make sure it could be fixed in 1.22 milestone). It gets fixed pretty fast. Thank you.


And I edited the description to make it clear. 😁

@wxiaoguang commented on GitHub (Mar 22, 2024): Oh yes, I just added it for remembering (to make sure it could be fixed in 1.22 milestone). It gets fixed pretty fast. Thank you. ---- And I edited the description to make it clear. 😁
Author
Owner

@wxiaoguang commented on GitHub (Mar 22, 2024):

For the first one: "can not save empty comment"

I think it could be considered as not a bug. I think it doesn't make sense to update to an empty content. Especially in some templates, it checks if .Content to use different layouts.

@wxiaoguang commented on GitHub (Mar 22, 2024): For the first one: "can not save empty comment" I think it could be considered as not a bug. I think it doesn't make sense to update to an empty content. Especially in some templates, it checks `if .Content` to use different layouts.
Author
Owner

@yp05327 commented on GitHub (Mar 25, 2024):

For the first one, actually what I want to say is that the JSON returns empty content, and we have no empty check in JS, so this will cause a bug here. Also for the dropzone-attachments. Although the second one was fixed, but you will still see it, if you want to clear the comment.

In the latest version (1.22.0+dev-1175-g428e05662f)
image
image

@yp05327 commented on GitHub (Mar 25, 2024): For the first one, actually what I want to say is that the JSON returns empty `content`, and we have no empty check in JS, so this will cause a bug here. Also for the `dropzone-attachments`. Although the second one was fixed, but you will still see it, if you want to `clear` the comment. In the latest version (1.22.0+dev-1175-g428e05662f) ![image](https://github.com/go-gitea/gitea/assets/18380374/2914b429-1d52-43b2-b414-7af1a97cd771) ![image](https://github.com/go-gitea/gitea/assets/18380374/613eb97d-15b7-4f29-a094-6b18ec6ac538)
Author
Owner

@yp05327 commented on GitHub (Apr 9, 2024):

I noticed that we have no empty checking in API, so users can "save empty comment" by using API but not from web UI.

API:
image
Web UI:
image

@yp05327 commented on GitHub (Apr 9, 2024): I noticed that we have no empty checking in API, so users can "save empty comment" by using API but not from web UI. API: ![image](https://github.com/go-gitea/gitea/assets/18380374/a1f6d053-9531-4282-a550-2574e8dc5448) Web UI: ![image](https://github.com/go-gitea/gitea/assets/18380374/ccc8b938-5157-4af9-aba6-f9c86855127c)
Author
Owner

@silverwind commented on GitHub (Apr 9, 2024):

I think we should do this (both UI and API):

  • Allow new Issue/PR creation with empty content
  • Allow editing of comments to become empty
  • Forbid creation of comment with empty content
@silverwind commented on GitHub (Apr 9, 2024): I think we should do this (both UI and API): - Allow new Issue/PR creation with empty content - Allow editing of comments to become empty - Forbid creation of comment with empty content
Author
Owner

@wxiaoguang commented on GitHub (Apr 25, 2024):

A quick fix: Allow to save empty comment #30706

@wxiaoguang commented on GitHub (Apr 25, 2024): A quick fix: Allow to save empty comment #30706
Author
Owner

@yp05327 commented on GitHub (Apr 26, 2024):

I think we should do this (both UI and API):

  • Allow new Issue/PR creation with empty content
  • Allow editing of comments to become empty
  • Forbid creation of comment with empty content

It seems that all of them will be finished after #30706 merged.

@yp05327 commented on GitHub (Apr 26, 2024): > I think we should do this (both UI and API): > > * Allow new Issue/PR creation with empty content > * Allow editing of comments to become empty > * Forbid creation of comment with empty content It seems that all of them will be finished after #30706 merged.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12701