diff --git a/packages/twenty-front/src/modules/views/view-picker/hooks/useGetAvailableFieldsForKanban.ts b/packages/twenty-front/src/modules/views/view-picker/hooks/useGetAvailableFieldsForKanban.ts index 1c595472bf6b..cbb6cfca07dc 100644 --- a/packages/twenty-front/src/modules/views/view-picker/hooks/useGetAvailableFieldsForKanban.ts +++ b/packages/twenty-front/src/modules/views/view-picker/hooks/useGetAvailableFieldsForKanban.ts @@ -37,7 +37,9 @@ export const useGetAvailableFieldsForKanban = () => { navigate( `/settings/objects/${getObjectSlug( objectMetadataItem, - )}/new-field/step-2?fieldType=${FieldMetadataType.Select}`, + )}/new-field/step-2?fieldType=${ + FieldMetadataType.Select + }&navigateBack=true`, ); } else { navigate(`/settings/objects`); diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetail.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetail.tsx index 2a54ec88fc31..3f551f7728f1 100644 --- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetail.tsx +++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetail.tsx @@ -1,7 +1,6 @@ import styled from '@emotion/styled'; import { useEffect } from 'react'; -import { useLocation, useNavigate, useParams } from 'react-router-dom'; -import { useSetRecoilState } from 'recoil'; +import { useNavigate, useParams } from 'react-router-dom'; import { H2Title, IconPlus, IconSettings } from 'twenty-ui'; import { LABEL_IDENTIFIER_FIELD_METADATA_TYPES } from '@/object-metadata/constants/LabelIdentifierFieldMetadataTypes'; @@ -33,7 +32,6 @@ import { TableHeader } from '@/ui/layout/table/components/TableHeader'; import { TableSection } from '@/ui/layout/table/components/TableSection'; import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb'; import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink'; -import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState'; const StyledDiv = styled.div` display: flex; @@ -43,11 +41,6 @@ const StyledDiv = styled.div` export const SettingsObjectDetail = () => { const navigate = useNavigate(); - const location = useLocation(); - const setNavigationMemorizedUrl = useSetRecoilState( - navigationMemorizedUrlState, - ); - setNavigationMemorizedUrl(location.pathname); const { objectSlug = '' } = useParams(); const { findActiveObjectMetadataItemBySlug } = diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx index 0ed39defc905..b5f23b2c2ee3 100644 --- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx +++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx @@ -5,7 +5,6 @@ import pick from 'lodash.pick'; import { useEffect, useState } from 'react'; import { FormProvider, useForm } from 'react-hook-form'; import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; -import { useRecoilValue } from 'recoil'; import { H2Title, IconSettings } from 'twenty-ui'; import { z } from 'zod'; @@ -30,7 +29,6 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer'; import { Section } from '@/ui/layout/section/components/Section'; import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb'; -import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState'; import { View } from '@/views/types/View'; import { ViewType } from '@/views/types/ViewType'; import { FieldMetadataType } from '~/generated-metadata/graphql'; @@ -48,11 +46,11 @@ const StyledSettingsObjectFieldTypeSelect = styled( `; export const SettingsObjectNewFieldStep2 = () => { - const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState); const navigate = useNavigate(); const { objectSlug = '' } = useParams(); const [searchParams] = useSearchParams(); const fieldType = searchParams.get('fieldType'); + const navigateBack = searchParams.get('navigateBack'); const { enqueueSnackBar } = useSnackBar(); const { findActiveObjectMetadataItemBySlug } = @@ -150,7 +148,11 @@ export const SettingsObjectNewFieldStep2 = () => { }); } - navigate(navigationMemorizedUrl, { replace: true }); + if (navigateBack?.toLowerCase() === 'true') { + navigate(-1); + } else { + navigate(`/settings/objects/${objectSlug}`); + } // TODO: fix optimistic update logic // Forcing a refetch for now but it's not ideal @@ -198,7 +200,10 @@ export const SettingsObjectNewFieldStep2 = () => { navigate(navigationMemorizedUrl, { replace: true })} + onCancel={() => { + if (navigateBack?.toLowerCase() === 'true') navigate(-1); + else navigate(`/settings/objects/${objectSlug}`); + }} onSave={formConfig.handleSubmit(handleSave)} /> )}