Skip to content

The open alternative to Salesforce, designed for AI.

Fix create task (#7498)

Mariebe171e84d719
diff --git a/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts b/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts
index c35d2783712..1cc4af08a81 100644
--- a/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts
+++ b/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts
@@ -67,8 +67,8 @@ export const useOpenCreateActivityDrawer = ({
targetableObjects: ActivityTargetableObject[];
customAssignee?: WorkspaceMember;
}) => {
- openRightDrawer(RightDrawerPages.ViewRecord);
setIsNewViewableRecordLoading(true);
+ openRightDrawer(RightDrawerPages.ViewRecord);
setViewableRecordId(null);
setViewableRecordNameSingular(activityObjectNameSingular);
diff --git a/packages/twenty-front/src/modules/object-record/record-right-drawer/components/RightDrawerRecord.tsx b/packages/twenty-front/src/modules/object-record/record-right-drawer/components/RightDrawerRecord.tsx
index 6a76206e6e7..3a747b0913a 100644
--- a/packages/twenty-front/src/modules/object-record/record-right-drawer/components/RightDrawerRecord.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-right-drawer/components/RightDrawerRecord.tsx
@@ -1,5 +1,6 @@
import { useRecoilValue } from 'recoil';
+import { isNewViewableRecordLoadingState } from '@/object-record/record-right-drawer/states/isNewViewableRecordLoading';
import { viewableRecordIdState } from '@/object-record/record-right-drawer/states/viewableRecordIdState';
import { viewableRecordNameSingularState } from '@/object-record/record-right-drawer/states/viewableRecordNameSingularState';
import { RecordShowContainer } from '@/object-record/record-show/components/RecordShowContainer';
@@ -18,7 +19,19 @@ export const RightDrawerRecord = () => {
const viewableRecordNameSingular = useRecoilValue(
viewableRecordNameSingularState,
);
+ const isNewViewableRecordLoading = useRecoilValue(
+ isNewViewableRecordLoadingState,
+ );
const viewableRecordId = useRecoilValue(viewableRecordIdState);
+
+ if (!viewableRecordNameSingular && !isNewViewableRecordLoading) {
+ throw new Error(`Object name is not defined`);
+ }
+
+ if (!viewableRecordId && !isNewViewableRecordLoading) {
+ throw new Error(`Record id is not defined`);
+ }
+
const { objectNameSingular, objectRecordId } = useRecordShowPage(
viewableRecordNameSingular ?? '',
viewableRecordId ?? '',
@@ -27,12 +40,15 @@ export const RightDrawerRecord = () => {
return (
<StyledRightDrawerRecord>
<RecordFieldValueSelectorContextProvider>
- <RecordValueSetterEffect recordId={objectRecordId} />
+ {!isNewViewableRecordLoading && (
+ <RecordValueSetterEffect recordId={objectRecordId} />
+ )}
<RecordShowContainer
objectNameSingular={objectNameSingular}
objectRecordId={objectRecordId}
loading={false}
isInRightDrawer={true}
+ isNewRightDrawerItemLoading={isNewViewableRecordLoading}
/>
</RecordFieldValueSelectorContextProvider>
</StyledRightDrawerRecord>
diff --git a/packages/twenty-front/src/modules/object-record/record-show/components/RecordShowContainer.tsx b/packages/twenty-front/src/modules/object-record/record-show/components/RecordShowContainer.tsx
index f9176f49991..9b1e10601ab 100644
--- a/packages/twenty-front/src/modules/object-record/record-show/components/RecordShowContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-show/components/RecordShowContainer.tsx
@@ -21,7 +21,6 @@ import { RecordInlineCell } from '@/object-record/record-inline-cell/components/
import { PropertyBox } from '@/object-record/record-inline-cell/property-box/components/PropertyBox';
import { PropertyBoxSkeletonLoader } from '@/object-record/record-inline-cell/property-box/components/PropertyBoxSkeletonLoader';
import { InlineCellHotkeyScope } from '@/object-record/record-inline-cell/types/InlineCellHotkeyScope';
-import { isNewViewableRecordLoadingState } from '@/object-record/record-right-drawer/states/isNewViewableRecordLoading';
import { RecordDetailDuplicatesSection } from '@/object-record/record-show/record-detail-section/components/RecordDetailDuplicatesSection';
import { RecordDetailRelationSection } from '@/object-record/record-show/record-detail-section/components/RecordDetailRelationSection';
import { recordLoadingFamilyState } from '@/object-record/record-store/states/recordLoadingFamilyState';
@@ -49,6 +48,7 @@ type RecordShowContainerProps = {
objectRecordId: string;
loading: boolean;
isInRightDrawer?: boolean;
+ isNewRightDrawerItemLoading?: boolean;
};
export const RecordShowContainer = ({
@@ -56,6 +56,7 @@ export const RecordShowContainer = ({
objectRecordId,
loading,
isInRightDrawer = false,
+ isNewRightDrawerItemLoading = false,
}: RecordShowContainerProps) => {
const { objectMetadataItem } = useObjectMetadataItem({
objectNameSingular,
@@ -82,9 +83,6 @@ export const RecordShowContainer = ({
recordId: objectRecordId,
}),
);
- const isNewViewableRecordLoading = useRecoilValue(
- isNewViewableRecordLoadingState,
- );
const [uploadImage] = useUploadImageMutation();
const { updateOneRecord } = useUpdateOneRecord({ objectNameSingular });
@@ -166,8 +164,6 @@ export const RecordShowContainer = ({
const isReadOnly = objectMetadataItem.isRemote;
const isMobile = useIsMobile() || isInRightDrawer;
const isPrefetchLoading = useIsPrefetchLoading();
- const isNewRightDrawerItemLoading =
- isInRightDrawer && isNewViewableRecordLoading;
const summaryCard =
!isNewRightDrawerItemLoading && isDefined(recordFromStore) ? (
diff --git a/packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPage.ts b/packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPage.ts
index 7bdaf0b4284..fb73b8ce9a5 100644
--- a/packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPage.ts
+++ b/packages/twenty-front/src/modules/object-record/record-show/hooks/useRecordShowPage.ts
@@ -23,10 +23,10 @@ export const useRecordShowPage = (
objectRecordId: paramObjectRecordId,
} = useParams();
- const objectNameSingular = propsObjectNameSingular || paramObjectNameSingular;
- const objectRecordId = propsObjectRecordId || paramObjectRecordId;
+ const objectNameSingular = propsObjectNameSingular ?? paramObjectNameSingular;
+ const objectRecordId = propsObjectRecordId ?? paramObjectRecordId;
- if (!objectNameSingular || !objectRecordId) {
+ if (!isDefined(objectNameSingular) || !isDefined(objectRecordId)) {
throw new Error('Object name or Record id is not defined');
}