diff --git a/src/lib/components/admin/EssayForm.svelte b/src/lib/components/admin/EssayForm.svelte index b009774..a0159e9 100644 --- a/src/lib/components/admin/EssayForm.svelte +++ b/src/lib/components/admin/EssayForm.svelte @@ -170,13 +170,9 @@ $effect(() => { if (autoSave.status === 'saved') { return } - navigation.cancel() + // Flush any pending changes before allowing navigation to proceed try { await autoSave.flush() - // Navigate to the intended destination after flush completes - if (navigation.to?.url) { - goto(navigation.to.url.pathname + navigation.to.url.search) - } } catch (error) { console.error('Autosave flush failed:', error) } diff --git a/src/lib/components/admin/PhotoPostForm.svelte b/src/lib/components/admin/PhotoPostForm.svelte index a1a2094..9584039 100644 --- a/src/lib/components/admin/PhotoPostForm.svelte +++ b/src/lib/components/admin/PhotoPostForm.svelte @@ -174,13 +174,9 @@ $effect(() => { if (autoSave.status === 'saved') { return } - navigation.cancel() + // Flush any pending changes before allowing navigation to proceed try { await autoSave.flush() - // Navigate to the intended destination after flush completes - if (navigation.to?.url) { - goto(navigation.to.url.pathname + navigation.to.url.search) - } } catch (error) { console.error('Autosave flush failed:', error) } diff --git a/src/lib/components/admin/ProjectForm.svelte b/src/lib/components/admin/ProjectForm.svelte index 5454b36..e68a425 100644 --- a/src/lib/components/admin/ProjectForm.svelte +++ b/src/lib/components/admin/ProjectForm.svelte @@ -185,14 +185,9 @@ return } - // Otherwise, flush any pending changes before navigating - navigation.cancel() + // Otherwise, flush any pending changes before allowing navigation to proceed try { await autoSave.flush() - // Navigate to the intended destination after flush completes - if (navigation.to?.url) { - goto(navigation.to.url.pathname + navigation.to.url.search) - } } catch (error) { console.error('Autosave flush failed:', error) toast.error('Failed to save changes') diff --git a/src/lib/components/admin/SimplePostForm.svelte b/src/lib/components/admin/SimplePostForm.svelte index 17481fb..6a5c8f0 100644 --- a/src/lib/components/admin/SimplePostForm.svelte +++ b/src/lib/components/admin/SimplePostForm.svelte @@ -175,13 +175,9 @@ beforeNavigate(async (navigation) => { if (autoSave.status === 'saved') { return } - navigation.cancel() + // Flush any pending changes before allowing navigation to proceed try { await autoSave.flush() - // Navigate to the intended destination after flush completes - if (navigation.to?.url) { - goto(navigation.to.url.pathname + navigation.to.url.search) - } } catch (error) { console.error('Autosave flush failed:', error) } diff --git a/src/routes/admin/posts/[id]/edit/+page.svelte b/src/routes/admin/posts/[id]/edit/+page.svelte index c55f934..ff816a7 100644 --- a/src/routes/admin/posts/[id]/edit/+page.svelte +++ b/src/routes/admin/posts/[id]/edit/+page.svelte @@ -386,14 +386,9 @@ onMount(async () => { return } - // Otherwise, flush any pending changes before navigating - navigation.cancel() + // Otherwise, flush any pending changes before allowing navigation to proceed try { await autoSave.flush() - // Navigate to the intended destination after flush completes - if (navigation.to?.url) { - goto(navigation.to.url.pathname + navigation.to.url.search) - } } catch (error) { console.error('Autosave flush failed:', error) }