diff --git a/artifacts/tx-os/src/pages/notes.tsx b/artifacts/tx-os/src/pages/notes.tsx index 92f56a20..51c2b20c 100644 --- a/artifacts/tx-os/src/pages/notes.tsx +++ b/artifacts/tx-os/src/pages/notes.tsx @@ -286,14 +286,10 @@ export default function NotesPage() { setView("active"); // The top Composer is only mounted when // `view === "active" && folderSelection.kind !== "shared-folder"`. - // If the user arrived from /notes?new=1 while sitting inside a - // shared folder, leaving the selection alone would mean the - // Composer is never rendered and the open trigger would be lost. - // Reset to the default "all" folder so the composer is guaranteed - // visible regardless of where they were before. - setFolderSelection((cur) => - cur.kind === "shared-folder" ? { kind: "all" } : cur, - ); + // Always land on the default "all" folder so /notes?new=1 has a + // deterministic landing state and the composer is guaranteed + // mounted regardless of where the user was before. + setFolderSelection({ kind: "all" }); setComposerOpenTrigger((n) => n + 1); if (typeof window !== "undefined") { params.delete("new"); @@ -3566,10 +3562,14 @@ function Composer({ }; // External open trigger (e.g. /notes?new=1 from the meetings quick - // note tab). Skip the initial mount value (0) and only react to - // subsequent bumps, then focus + scroll the textarea into view. - const lastOpenTrigger = useRef(openTrigger); + // note tab). React both to subsequent bumps AND to the initial mount + // when the trigger is already > 0 — this covers the case where the + // page resets folder selection and the Composer mounts fresh with a + // non-zero trigger (e.g. user was in a shared folder and clicked the + // quick-note tab). + const lastOpenTrigger = useRef(0); useEffect(() => { + if (openTrigger === 0) return; if (openTrigger === lastOpenTrigger.current) return; lastOpenTrigger.current = openTrigger; setOpen(true);