From 52beae85b3b627c4c225d4c3474b6aa17736dbe8 Mon Sep 17 00:00:00 2001 From: claude code agent 227 Date: Sat, 4 Jul 2026 12:06:45 +0300 Subject: [PATCH] fix(client): close mobile sidebar drawer after creating a page (#325) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On mobile the "create page" action is triggered from inside the off-canvas sidebar drawer (the space sidebar "+" and temporary-note buttons, and the tree-row "add subpage"). handleCreate navigated to the new page's editor route but never closed that drawer, so it stayed open on top of the freshly created page — the editor was hidden behind the page tree ("as if the page didn't open", #325 item 5). Close the mobile sidebar (`setMobileSidebar(false)`) right after navigating, mirroring the existing drawer-close on a tree-row tap (space-tree-row). Placing it in handleCreate covers all three create entry points in one spot. It is a no-op on desktop, where the mobile-sidebar atom is already false and only governs the sub-992px collapsed state — desktop behavior is unchanged. Verified: `tsc --noEmit` clean; client vitest 887 passed | 1 expected-fail. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../page/tree/hooks/use-tree-mutation.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/client/src/features/page/tree/hooks/use-tree-mutation.ts b/apps/client/src/features/page/tree/hooks/use-tree-mutation.ts index 494f8b93..7aff8141 100644 --- a/apps/client/src/features/page/tree/hooks/use-tree-mutation.ts +++ b/apps/client/src/features/page/tree/hooks/use-tree-mutation.ts @@ -1,5 +1,5 @@ import { useCallback } from "react"; -import { useAtom, useStore } from "jotai"; +import { useAtom, useSetAtom, useStore } from "jotai"; import { notifications } from "@mantine/notifications"; import { useTranslation } from "react-i18next"; import { useNavigate, useParams } from "react-router-dom"; @@ -20,6 +20,7 @@ import { } from "@/features/page/queries/page-query.ts"; import { buildPageUrl } from "@/features/page/page.utils.ts"; import { getSpaceUrl } from "@/lib/config.ts"; +import { mobileSidebarAtom } from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts"; export type UseTreeMutation = { handleMove: (sourceId: string, op: DropOp) => Promise; @@ -43,6 +44,7 @@ export function useTreeMutation(spaceId: string): UseTreeMutation { const removePageMutation = useRemovePageMutation(); const movePageMutation = useMovePageMutation(); const navigate = useNavigate(); + const setMobileSidebar = useSetAtom(mobileSidebarAtom); const { spaceSlug, pageSlug } = useParams(); const handleMove = useCallback( @@ -201,8 +203,23 @@ export function useTreeMutation(spaceId: string): UseTreeMutation { createdPage.title, ); navigate(pageUrl); + // On mobile the create action is triggered from inside the off-canvas + // sidebar drawer (space sidebar "+", tree-row "add subpage"). Navigating + // alone leaves that drawer open on top of the freshly created page, so the + // editor stays hidden behind the tree. Close it here so the new page opens + // in the editor — mirrors the row-click drawer-close in space-tree-row. + // No-op on desktop, where the mobile drawer atom is already false. + setMobileSidebar(false); }, - [spaceId, createPageMutation, setData, store, navigate, spaceSlug], + [ + spaceId, + createPageMutation, + setData, + store, + navigate, + spaceSlug, + setMobileSidebar, + ], ); const handleRename = useCallback( -- 2.52.0