From 2804ace90efce3fbf279af841715d129b48bfad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignas=20Lun=C4=97nas?= <34475426+lunenas@users.noreply.github.com> Date: Mon, 30 Mar 2026 09:37:25 +0300 Subject: [PATCH] fix: preserve pagination params when opening CMS item sheet navigateToCollectionItem was replacing all URL query params with only the edit param, dropping limit/page/search. The URL sync effect then reset pageSize to 25, causing items beyond position 25 to disappear and the sheet to show "Create Item" instead of "Edit". Made-with: Cursor --- app/ycode/components/CMS.tsx | 4 ++-- hooks/use-editor-url.ts | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/ycode/components/CMS.tsx b/app/ycode/components/CMS.tsx index 5ee07412..780fb19c 100644 --- a/app/ycode/components/CMS.tsx +++ b/app/ycode/components/CMS.tsx @@ -2145,7 +2145,7 @@ const CMS = React.memo(function CMS() { setShowItemSheet(false); setEditingItem(null); if (selectedCollectionId) { - navigateToCollection(selectedCollectionId); + navigateToCollection(selectedCollectionId, currentPage, searchQuery || undefined, pageSize); } } }} @@ -2155,7 +2155,7 @@ const CMS = React.memo(function CMS() { setShowItemSheet(false); setEditingItem(null); if (selectedCollectionId) { - navigateToCollection(selectedCollectionId); + navigateToCollection(selectedCollectionId, currentPage, searchQuery || undefined, pageSize); } }} /> diff --git a/hooks/use-editor-url.ts b/hooks/use-editor-url.ts index f9c75dbb..9a4ca0b3 100644 --- a/hooks/use-editor-url.ts +++ b/hooks/use-editor-url.ts @@ -330,14 +330,26 @@ export function useEditorUrl() { const navigateToCollectionItem = useCallback( (collectionId: string, itemRId: string) => { - router.push(`/ycode/collections/${collectionId}?edit=${itemRId}`); + const currentParams = new URLSearchParams(window.location.search); + const params = new URLSearchParams(); + params.set('edit', itemRId); + if (currentParams.has('page')) params.set('page', currentParams.get('page')!); + if (currentParams.has('limit')) params.set('limit', currentParams.get('limit')!); + if (currentParams.has('search')) params.set('search', currentParams.get('search')!); + router.push(`/ycode/collections/${collectionId}?${params.toString()}`); }, [router] ); const navigateToNewCollectionItem = useCallback( (collectionId: string) => { - router.push(`/ycode/collections/${collectionId}?new`); + const currentParams = new URLSearchParams(window.location.search); + const params = new URLSearchParams(); + params.set('new', ''); + if (currentParams.has('page')) params.set('page', currentParams.get('page')!); + if (currentParams.has('limit')) params.set('limit', currentParams.get('limit')!); + if (currentParams.has('search')) params.set('search', currentParams.get('search')!); + router.push(`/ycode/collections/${collectionId}?${params.toString()}`); }, [router] );