From 02e163f8d7ea9a9020ce70dde86d45a2ea54d2b3 Mon Sep 17 00:00:00 2001 From: boojack Date: Tue, 20 Oct 2026 21:57:16 +0800 Subject: [PATCH] fix(web): render the Home composer with the page The editing session became a lazy chunk in #6481, so a signed-in user's Home showed a blank card until the chunk arrived, then the feed jumped up 18px when the real composer replaced it. The Home and Explore routes of a signed-in user now load the session's code together with the page, so the composer renders with the page as it did before the split; visitors keep the lighter page. Where a draft can still suspend, the fallback is a still of the empty composer with the same frame, placeholder line and toolbar height, so nothing moves when the session takes its place. --- web/src/components/MemoEditor/MemoEditor.tsx | 8 +++++++- web/src/components/MemoEditor/README.md | 2 +- web/src/router/index.tsx | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/web/src/components/MemoEditor/MemoEditor.tsx b/web/src/components/MemoEditor/MemoEditor.tsx index 032deef07..e67c72fc7 100644 --- a/web/src/components/MemoEditor/MemoEditor.tsx +++ b/web/src/components/MemoEditor/MemoEditor.tsx @@ -162,8 +162,14 @@ const MemoEditorDraft = ({ draft, ...editing }: MemoEditorDraftProps) => { const identity: MemoEditIdentity = draft.parent ? { kind: "comment", parent: draft.parent } : { kind: "new", scope: draft.scope ?? "default", space: draft.space }; + // While the session's code loads, a still of the empty composer: the same frame, the + // placeholder line and the toolbar's height, so the page below does not move when the + // session takes its place. const fallback = editing.frameless ? null : ( -
+
+
{editing.placeholder ?? " "}
+
+
); return ( diff --git a/web/src/components/MemoEditor/README.md b/web/src/components/MemoEditor/README.md index eaa8c5b76..2c8ca39b9 100644 --- a/web/src/components/MemoEditor/README.md +++ b/web/src/components/MemoEditor/README.md @@ -61,7 +61,7 @@ Hosts of a new top-level memo pass `useMemoSuggestions()` into `suggestions`; ed - **Inline** (Home, panels): the session brings its own frame. The + menu offers focus mode, which expands it over the page; the exit button minimizes it back. - **Hosted** (`onFocusModeExit`): a host presents the session full-screen and owns that frame (`contexts/GlobalMemoEditorContext.tsx`). It mounts straight into focus mode and exits by calling back to dismiss the host. -The session's code is a chunk of its own, loaded when a memo is first edited or composed, and renders without suspending once loaded; a host that knows an editor is coming calls `preloadMemoEditing()`. +The session's code is a chunk of its own, loaded when a memo is first edited or composed, and renders without suspending once loaded. A host that knows an editor is coming calls `preloadMemoEditing()`: the router loads it with the Home page for a signed-in user, so the composer renders with the page, and the comment section loads it while the pointer is on its button. Until it is loaded a new draft shows a still of the empty composer, the same frame, placeholder line and toolbar height, so nothing moves when the session takes its place. ### Destination and visibility diff --git a/web/src/router/index.tsx b/web/src/router/index.tsx index ff2433ea9..e3466e345 100644 --- a/web/src/router/index.tsx +++ b/web/src/router/index.tsx @@ -1,6 +1,7 @@ import { createBrowserRouter, Navigate, type RouteObject, useLocation } from "react-router-dom"; import App from "@/App"; import { ChunkLoadErrorFallback } from "@/components/ErrorBoundary"; +import { preloadMemoEditing } from "@/components/MemoEditor"; import { useAuth } from "@/contexts/AuthContext"; import useCurrentUser from "@/hooks/useCurrentUser"; import MainLayout from "@/layouts/MainLayout"; @@ -18,6 +19,9 @@ const AuthCallback = lazyWithReload(() => import("@/pages/AuthCallback")); const MemoMap = lazyWithReload(() => import("@/pages/Map")); const Calendar = lazyWithReload(() => import("@/pages/Calendar")); const Home = lazyWithReload(() => import("@/pages/Home")); +// A signed-in user's Home composes at once, so the page's code arrives together with the +// editing session's and the composer renders with the page, never after it. +const ComposingHome = lazyWithReload(() => Promise.all([import("@/pages/Home"), preloadMemoEditing()]).then(([page]) => page)); const Inboxes = lazyWithReload(() => import("@/pages/Inboxes")); const MemoDetail = lazyWithReload(() => import("@/pages/MemoDetail")); const NotFound = lazyWithReload(() => import("@/pages/NotFound")); @@ -36,14 +40,15 @@ const HomeRoute = () => { if (!currentUser && !getCollectionCreator(location.search)) { return ; } - return ; + return currentUser ? : ; }; const ExploreRoute = () => { + const currentUser = useCurrentUser(); const location = useLocation(); const search = withCollectionCreator(location.search); if (search !== location.search) return ; - return ; + return currentUser ? : ; }; // Backward compatibility alias.