Skip to content

The open alternative to Salesforce, designed for AI.

Fix composite field edition (#12095)

Thomas Trompetteeca5ef7cfe9b
diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellContainer.tsx b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellContainer.tsx
index 0ca05809891..fa81021da9b 100644
--- a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellContainer.tsx
@@ -43,7 +43,6 @@ const StyledLabelAndIconContainer = styled.div`
`;
const StyledValueContainer = styled.div<{ readonly: boolean }>`
- cursor: ${({ readonly }) => (readonly ? 'default' : 'pointer')};
display: flex;
min-width: 0;
position: relative;
@@ -72,7 +71,7 @@ const StyledLabelContainer = styled.div<{ width?: number }>`
width: ${({ width }) => width}px;
`;
-const StyledInlineCellBaseContainer = styled.div`
+const StyledInlineCellBaseContainer = styled.div<{ readonly: boolean }>`
box-sizing: border-box;
width: 100%;
display: flex;
@@ -80,6 +79,7 @@ const StyledInlineCellBaseContainer = styled.div`
gap: ${({ theme }) => theme.spacing(1)};
user-select: none;
align-items: center;
+ cursor: ${({ readonly }) => (readonly ? 'default' : 'pointer')};
`;
export const StyledSkeletonDiv = styled.div`
@@ -96,22 +96,19 @@ export const RecordInlineCellContainer = () => {
editModeContentOnly,
} = useRecordInlineCellContext();
+ const { isInlineCellInEditMode, openInlineCell } = useInlineCell();
+
const { recordId, fieldDefinition } = useContext(FieldContext);
+ const shouldContainerBeClickable =
+ !readonly && !editModeContentOnly && !isInlineCellInEditMode;
+
if (isFieldText(fieldDefinition)) {
assertFieldMetadata(FieldMetadataType.TEXT, isFieldText, fieldDefinition);
}
const { setIsFocused } = useFieldFocus();
- const { openInlineCell } = useInlineCell();
-
- const handleDisplayModeClick = () => {
- if (!readonly && !editModeContentOnly) {
- openInlineCell();
- }
- };
-
const handleContainerMouseEnter = () => {
if (!readonly) {
setIsFocused(true);
@@ -132,9 +129,10 @@ export const RecordInlineCellContainer = () => {
return (
<StyledInlineCellBaseContainer
+ readonly={readonly ?? false}
onMouseEnter={handleContainerMouseEnter}
onMouseLeave={handleContainerMouseLeave}
- onClick={handleDisplayModeClick}
+ onClick={shouldContainerBeClickable ? openInlineCell : undefined}
>
{(IconLabel || label) && (
<StyledLabelAndIconContainer id={labelId}>
diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellValue.tsx b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellValue.tsx
index e9ff2c3d3f5..5d369a42eba 100644
--- a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellValue.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellValue.tsx
@@ -50,19 +50,11 @@ export const RecordInlineCellValue = () => {
{!readonly && isInlineCellInEditMode && (
<RecordInlineCellEditMode>{editModeContent}</RecordInlineCellEditMode>
)}
- {editModeContentOnly ? (
- <StyledClickableContainer readonly={readonly} isCentered={isCentered}>
- <RecordInlineCellDisplayMode>
- {editModeContent}
- </RecordInlineCellDisplayMode>
- </StyledClickableContainer>
- ) : (
- <StyledClickableContainer readonly={readonly} isCentered={isCentered}>
- <RecordInlineCellDisplayMode>
- {displayModeContent}
- </RecordInlineCellDisplayMode>
- </StyledClickableContainer>
- )}
+ <StyledClickableContainer readonly={readonly} isCentered={isCentered}>
+ <RecordInlineCellDisplayMode>
+ {editModeContentOnly ? editModeContent : displayModeContent}
+ </RecordInlineCellDisplayMode>
+ </StyledClickableContainer>
</>
);
};