From a683827e4b004244602bfdf3af01ef02fdd00e34 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Thu, 27 Mar 2025 19:29:34 +0100 Subject: [PATCH] Fix inline cell height issue and allow field settings update (#11248) In this PR: - allow to update settings on fields metadata (regression introduced by a recent refactoring of fields-metadata update) - revert changes introduced by https://github.com/twentyhq/twenty/pull/11221 --- .../components/RecordInlineCellContainer.tsx | 21 +++++-------------- .../RecordInlineCellDisplayMode.tsx | 2 ++ .../hooks/before-update-one-field.hook.ts | 19 ++++++++++++++++- 3 files changed, 25 insertions(+), 17 deletions(-) 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 db37f958e..174674b8f 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 @@ -38,6 +38,7 @@ const StyledLabelAndIconContainer = styled.div` display: flex; gap: ${({ theme }) => theme.spacing(1)}; height: 18px; + padding-top: 3px; `; const StyledValueContainer = styled.div` @@ -53,16 +54,11 @@ const StyledLabelContainer = styled.div<{ width?: number }>` width: ${({ width }) => width}px; `; -const StyledInlineCellBaseContainer = styled.div<{ - isDisplayModeFixHeight?: boolean; -}>` +const StyledInlineCellBaseContainer = styled.div` box-sizing: border-box; width: 100%; display: flex; - line-height: ${({ isDisplayModeFixHeight }) => - isDisplayModeFixHeight ? `24px` : `18px`}; - height: ${({ isDisplayModeFixHeight }) => - isDisplayModeFixHeight ? `24px` : `18px`}; + height: fit-content; gap: ${({ theme }) => theme.spacing(1)}; user-select: none; align-items: center; @@ -74,14 +70,8 @@ export const StyledSkeletonDiv = styled.div` `; export const RecordInlineCellContainer = () => { - const { - readonly, - IconLabel, - label, - labelWidth, - showLabel, - isDisplayModeFixHeight, - } = useRecordInlineCellContext(); + const { readonly, IconLabel, label, labelWidth, showLabel } = + useRecordInlineCellContext(); const { recordId, fieldDefinition } = useContext(FieldContext); @@ -111,7 +101,6 @@ export const RecordInlineCellContainer = () => { return ( diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellDisplayMode.tsx b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellDisplayMode.tsx index 9de0f4671..74518ed29 100644 --- a/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellDisplayMode.tsx +++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellDisplayMode.tsx @@ -44,6 +44,8 @@ const StyledRecordInlineCellNormalModeInnerContainer = styled.div` align-items: center; color: ${({ theme }) => theme.font.color.primary}; height: fit-content; + padding-top: 3px; + padding-bottom: 3px; overflow: hidden; text-overflow: ellipsis; diff --git a/packages/twenty-server/src/engine/metadata-modules/field-metadata/hooks/before-update-one-field.hook.ts b/packages/twenty-server/src/engine/metadata-modules/field-metadata/hooks/before-update-one-field.hook.ts index 463a99bbd..03cc95a51 100644 --- a/packages/twenty-server/src/engine/metadata-modules/field-metadata/hooks/before-update-one-field.hook.ts +++ b/packages/twenty-server/src/engine/metadata-modules/field-metadata/hooks/before-update-one-field.hook.ts @@ -75,7 +75,12 @@ export class BeforeUpdateOneField locale?: keyof typeof APP_LOCALES, ): UpdateOneInputType { const update: StandardFieldUpdate = {}; - const updatableFields = ['isActive', 'isLabelSyncedWithName', 'options']; + const updatableFields = [ + 'isActive', + 'isLabelSyncedWithName', + 'options', + 'settings', + ]; const overridableFields = ['label', 'icon', 'description']; const nonUpdatableFields = Object.keys(instance.update).filter( @@ -110,6 +115,7 @@ export class BeforeUpdateOneField this.handleLabelSyncedWithNameField(instance, update); this.handleStandardOverrides(instance, fieldMetadata, update, locale); this.handleOptionsField(instance, update); + this.handleSettingsField(instance, update); return { id: instance.id, @@ -128,6 +134,17 @@ export class BeforeUpdateOneField update.options = instance.update.options; } + private handleSettingsField( + instance: UpdateOneInputType, + update: StandardFieldUpdate, + ): void { + if (!isDefined(instance.update.settings)) { + return; + } + + update.settings = instance.update.settings; + } + private handleActiveField( instance: UpdateOneInputType, update: StandardFieldUpdate,