Skip to content

The open alternative to Salesforce, designed for AI.

Fix table re-renders on update field (#6722)

Lucas Bordeau6467da5cabb2
diff --git a/packages/twenty-front/src/modules/object-record/record-store/contexts/RecordFieldValueSelectorContext.tsx b/packages/twenty-front/src/modules/object-record/record-store/contexts/RecordFieldValueSelectorContext.tsx
index a83d4353171..1a6bc529a16 100644
--- a/packages/twenty-front/src/modules/object-record/record-store/contexts/RecordFieldValueSelectorContext.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-store/contexts/RecordFieldValueSelectorContext.tsx
@@ -30,22 +30,22 @@ export const useSetRecordValue = () => {
export const useRecordValue = (recordId: string) => {
const tableValue = useContextSelector(
RecordFieldValueSelectorContext,
- (value) => value[0],
+ (value) => value[0]?.[recordId],
);
- return tableValue?.[recordId] as ObjectRecord | undefined;
+ return tableValue as ObjectRecord | undefined;
};
export const useRecordFieldValue = <T,>(
recordId: string,
fieldName: string,
) => {
- const recordFieldValues = useContextSelector(
+ const recordFieldValue = useContextSelector(
RecordFieldValueSelectorContext,
- (value) => value[0],
+ (value) => value[0]?.[recordId]?.[fieldName],
);
- return recordFieldValues?.[recordId]?.[fieldName] as T;
+ return recordFieldValue as T | undefined;
};
export const useSetRecordFieldValue = () => {
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/EmailDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/EmailDisplay.tsx
index 60b8ef99669..2fe096c1762 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/EmailDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/EmailDisplay.tsx
@@ -20,7 +20,7 @@ const validateEmail = (email: string) => {
};
type EmailDisplayProps = {
- value: string | null;
+ value: string | null | undefined;
};
export const EmailDisplay = ({ value }: EmailDisplayProps) => {
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/NumberDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/NumberDisplay.tsx
index 5a8dc13c3e6..1834e502a05 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/NumberDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/NumberDisplay.tsx
@@ -3,7 +3,7 @@ import { formatNumber } from '~/utils/format/number';
import { EllipsisDisplay } from './EllipsisDisplay';
type NumberDisplayProps = {
- value: string | number | null;
+ value: string | number | null | undefined;
};
export const NumberDisplay = ({ value }: NumberDisplayProps) => (
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx
index f4cdc8519dc..d18ac35109a 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx
@@ -1,11 +1,11 @@
-import { MouseEvent } from 'react';
import { parsePhoneNumber, PhoneNumber } from 'libphonenumber-js';
+import { MouseEvent } from 'react';
import { ContactLink } from '@/ui/navigation/link/components/ContactLink';
import { isDefined } from '~/utils/isDefined';
type PhoneDisplayProps = {
- value: string | null;
+ value: string | null | undefined;
};
// TODO: see if we can find a faster way to format the phone number