diff --git a/web/app/(app)/pages/client.tsx b/web/app/(app)/pages/client.tsx index 402cc6e..2e3ede7 100644 --- a/web/app/(app)/pages/client.tsx +++ b/web/app/(app)/pages/client.tsx @@ -175,8 +175,17 @@ export function PagesClient({ initialId }: { initialId: string | null }) { } // The sidebar can create or open pages while this workspace stays mounted. + // Navigating to /pages with NO id (the "All pages" info view) must drop the + // open page, otherwise a client-side navigation keeps the editor mounted. useEffect(() => { - if (!initialId || initialId === activePage.current) return + if (!initialId) { + const cur = activePage.current + const clear = () => { activePage.current = null; setActiveId(null); setPage(null); notifyActivePage(null) } + if (cur) void autosave.flush(cur).then(clear) + else clear() + return + } + if (initialId === activePage.current) return void loadPages() void select(initialId) }, [initialId])