From 841dbb477b95b398fec167ceeb8e06fb995c33da Mon Sep 17 00:00:00 2001 From: Nitin Koche Date: Sun, 18 Aug 2024 21:41:37 +0530 Subject: [PATCH] preserve navigation state --- .../RecordIndexBoardDataLoaderEffect.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardDataLoaderEffect.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardDataLoaderEffect.tsx index a7f6bf62182a..ba3abec91e75 100644 --- a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardDataLoaderEffect.tsx +++ b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardDataLoaderEffect.tsx @@ -1,5 +1,5 @@ import { useCallback, useEffect } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; import { useRecoilValue, useSetRecoilState } from 'recoil'; import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; @@ -11,6 +11,7 @@ import { recordIndexFieldDefinitionsState } from '@/object-record/record-index/s import { recordIndexIsCompactModeActiveState } from '@/object-record/record-index/states/recordIndexIsCompactModeActiveState'; import { recordIndexKanbanFieldMetadataIdState } from '@/object-record/record-index/states/recordIndexKanbanFieldMetadataIdState'; import { computeRecordBoardColumnDefinitionsFromObjectMetadata } from '@/object-record/utils/computeRecordBoardColumnDefinitionsFromObjectMetadata'; +import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState'; import { FieldMetadataType } from '~/generated-metadata/graphql'; import { isDefined } from '~/utils/isDefined'; @@ -60,10 +61,21 @@ export const RecordIndexBoardDataLoaderEffect = ({ }, [recordIndexFieldDefinitions, setFieldDefinitions]); const navigate = useNavigate(); + const location = useLocation(); + const setNavigationMemorizedUrl = useSetRecoilState( + navigationMemorizedUrlState, + ); + const navigateToSelectSettings = useCallback(() => { - console.log('hehe'); + setNavigationMemorizedUrl(location.pathname + location.search); navigate(`/settings/objects/${getObjectSlug(objectMetadataItem)}`); - }, [navigate, objectMetadataItem]); + }, [ + navigate, + objectMetadataItem, + location.pathname, + location.search, + setNavigationMemorizedUrl, + ]); const { resetRecordSelection } = useRecordBoardSelection(recordBoardId); @@ -81,7 +93,6 @@ export const RecordIndexBoardDataLoaderEffect = ({ ); }, [ navigateToSelectSettings, - objectMetadataItem, objectNameSingular, recordIndexKanbanFieldMetadataId,