Skip to content

Commit 55171f0

Browse files
committed
fix: UP-21 preserve new content after save (don't call cancel post-save)
AcbMsgEditCancel was called after a successful save, which restored the original bubble content from dataset.originalContent, overwriting the freshly rendered new text. Fix: instead of calling cancel, inline the cleanup (remove msg-editing class, re-enable edit button, clear dataset) so the new content rendered by AcbMessageRenderer is preserved. Test: add assertion that bubble.textContent === 'new text' after save.
1 parent 009e6cb commit 55171f0

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

frontend/src/__tests__/message-edit.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ function installGlobals(apiFn) {
9090
}
9191
indicator.title = `Edited (v${resp.version})`;
9292
indicator.textContent = 'edited';
93-
window.AcbMsgEditCancel(row);
93+
// Close editing mode without restoring old content (cancel would overwrite new text)
94+
row.classList.remove('msg-editing');
95+
const editBtn = row.querySelector('.msg-edit-btn');
96+
if (editBtn) editBtn.disabled = false;
97+
delete bubbleEl.dataset.originalContent;
9498
} catch (err) {
9599
saveBtn.disabled = false;
96100
saveBtn.textContent = 'Save';
@@ -308,6 +312,8 @@ describe('UP-21: Save edit', () => {
308312
const indicator = row.querySelector('.msg-edited-indicator');
309313
expect(indicator).not.toBeNull();
310314
expect(indicator.textContent).toBe('edited');
315+
// bubble content must be the NEW text, not the original (regression guard for originalContent bug)
316+
expect(row.querySelector('.bubble-v2').textContent).toBe('new text');
311317
});
312318

313319
it('no_change response cancels editing without creating indicator', async () => {

src/static/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,11 @@
15791579
}
15801580
indicator.title = `Edited (v${resp.version})`;
15811581
indicator.textContent = 'edited';
1582-
window.AcbMsgEditCancel(row);
1582+
// Close editing mode without restoring old content (cancel would overwrite new text)
1583+
row.classList.remove('msg-editing');
1584+
const editBtn = row.querySelector('.msg-edit-btn');
1585+
if (editBtn) editBtn.disabled = false;
1586+
delete bubbleEl.dataset.originalContent;
15831587
} catch (err) {
15841588
saveBtn.disabled = false;
15851589
saveBtn.textContent = 'Save';

0 commit comments

Comments
 (0)