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] );