From 2896dac5369e6f2a8847c127e4bd9ecd4b82c098 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 16 Feb 2026 01:49:03 +0100 Subject: [PATCH] Fix state desync in ComboMarkdownEditor (#36625) Fixes https://github.com/go-gitea/gitea/issues/24253 When a tasklist checkbox is clicked, the tasklist code [updates `.raw-content` with latest server data](https://github.com/go-gitea/gitea/blob/7a8fe9eb370c6f3f5ec6eae2e1ebba5ac77b1f25/web_src/js/markup/tasklist.ts#L73) in the DOM after POSTing. Then when "Edit" is clicked the ComboMarkdownEditor is shown with a stale value from the previous edit session. The fix makes it always read from `.raw-content`, no server syncronization necessary because the value in `.raw-content` is the latest from the server. --------- Co-authored-by: wxiaoguang --- web_src/js/features/repo-issue-edit.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/web_src/js/features/repo-issue-edit.ts b/web_src/js/features/repo-issue-edit.ts index 3838c4f0416..4a112368f46 100644 --- a/web_src/js/features/repo-issue-edit.ts +++ b/web_src/js/features/repo-issue-edit.ts @@ -97,11 +97,9 @@ async function tryOnEditContent(e: Event) { cancelButton.addEventListener('click', cancelAndReset); form.addEventListener('submit', saveAndRefresh); } - - // FIXME: ideally here should reload content and attachment list from backend for existing editor, to avoid losing data - if (!comboMarkdownEditor.value()) { - comboMarkdownEditor.value(rawContent.textContent); - } + // when the content has changed on server side, there is no sync, and this page doesn't have the latest content, + // the editor still shows the old content, server will reject end user's submit by "data-content-version" check + comboMarkdownEditor.value(rawContent.textContent); comboMarkdownEditor.switchTabToEditor(); comboMarkdownEditor.focus(); triggerUploadStateChanged(comboMarkdownEditor.container);