From d6acf85252370c9faee50328644bca2b879a6f77 Mon Sep 17 00:00:00 2001 From: nmemmert Date: Tue, 16 Jun 2026 11:54:39 -0400 Subject: [PATCH] Fix Save Draft always showing Unsaved after save The snapshot was set from buildSiteContentForSave(form) which runs normalizeSiteContentForAdmin and rebuilds study objects, producing a JSON string that never matched the raw form state. isDirty therefore stayed true permanently after every save. Fix by capturing JSON.stringify(form) before the fetch and using that as the snapshot, so isDirty correctly clears on success. Co-Authored-By: Claude Sonnet 4.6 --- src/AdminPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AdminPage.tsx b/src/AdminPage.tsx index 4cb2da7..099165d 100644 --- a/src/AdminPage.tsx +++ b/src/AdminPage.tsx @@ -1468,6 +1468,7 @@ export default function AdminPage({ content, onSave, onLogout }: Props) { async function handleSaveDraft() { const payload = buildSiteContentForSave(form) + const formSnapshot = JSON.stringify(form) setStatus('saving') setErrorMsg('') try { @@ -1482,7 +1483,7 @@ export default function AdminPage({ content, onSave, onLogout }: Props) { } const data = await res.json() as { updatedAt?: string } setPublishState(prev => ({ ...prev, draftUpdatedAt: data.updatedAt ?? new Date().toISOString() })) - setLastSavedSnapshot(JSON.stringify(payload)) + setLastSavedSnapshot(formSnapshot) clearAutosaveDraft() setStatus('saved') if (saveStatusTimeoutRef.current !== null) {