From 831b2c4a39ae5dcd1ea1d97b9ece9fbab010c991 Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Mon, 4 May 2026 06:13:02 +0000 Subject: [PATCH] fix(twenty-front): add RICH_TEXT to FIELD_NOT_OVERWRITTEN_AT_DRAFT to prevent table cell crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sonarly.com/issue/33822?type=bug Pressing any text key while focused on a RICH_TEXT table cell (e.g., the `bodyV2` column on the Tasks view) throws an unhandled error because `computeDraftValueFromString` has no case for the RICH_TEXT field type, hitting the fallback throw. Fix: **Three changes, all in `twenty-front`:** 1. **`FieldsNotOverwrittenAtDraft.ts`** — Added `FieldMetadataType.RICH_TEXT` to the `FIELD_NOT_OVERWRITTEN_AT_DRAFT` array, alphabetically between RATING and SELECT. This is the primary fix. When a user presses a key while focused on a table cell, `useInitDraftValue` checks this array. If the field type is listed, it uses `computeDraftValueFromFieldValue` (which reads the existing record value and works for all types) instead of `computeDraftValueFromString` (which tries to convert a single keystroke into a type-specific draft). RICH_TEXT fields use BlockNote/TipTap editors and cannot create a meaningful draft from a single character — same reason ADDRESS, PHONES, LINKS, SELECT, etc. are already in this list. 2. **`computeDraftValueFromString.ts`** — Fixed a stray `}` in the error message template literal. The string was `` `...${fieldDefinition.type}}` `` (double closing brace producing "RICH_TEXT}") instead of `` `...${fieldDefinition.type}` ``. 3. **`computeEmptyDraftValue.ts`** — Fixed the same stray `}` typo in the error message template literal (identical pattern). --- .../object-record/constants/FieldsNotOverwrittenAtDraft.ts | 1 + .../record-field/ui/utils/computeDraftValueFromString.ts | 2 +- .../record-field/ui/utils/computeEmptyDraftValue.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/twenty-front/src/modules/object-record/constants/FieldsNotOverwrittenAtDraft.ts b/packages/twenty-front/src/modules/object-record/constants/FieldsNotOverwrittenAtDraft.ts index d3047e736b6..a8cf79c59fd 100644 --- a/packages/twenty-front/src/modules/object-record/constants/FieldsNotOverwrittenAtDraft.ts +++ b/packages/twenty-front/src/modules/object-record/constants/FieldsNotOverwrittenAtDraft.ts @@ -6,6 +6,7 @@ export const FIELD_NOT_OVERWRITTEN_AT_DRAFT = [ FieldMetadataType.LINKS, FieldMetadataType.MULTI_SELECT, FieldMetadataType.RATING, + FieldMetadataType.RICH_TEXT, FieldMetadataType.SELECT, FieldMetadataType.FILES, ]; diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/utils/computeDraftValueFromString.ts b/packages/twenty-front/src/modules/object-record/record-field/ui/utils/computeDraftValueFromString.ts index 1645213f6f8..900807a462f 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/ui/utils/computeDraftValueFromString.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/ui/utils/computeDraftValueFromString.ts @@ -83,7 +83,7 @@ export const computeDraftValueFromString = ({ } throw new CustomError( - `Record field type not supported : ${fieldDefinition.type}}`, + `Record field type not supported : ${fieldDefinition.type}`, 'RECORD_FIELD_TYPE_NOT_SUPPORTED', ); }; diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/utils/computeEmptyDraftValue.ts b/packages/twenty-front/src/modules/object-record/record-field/ui/utils/computeEmptyDraftValue.ts index d34ec911960..5105231bb99 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/ui/utils/computeEmptyDraftValue.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/ui/utils/computeEmptyDraftValue.ts @@ -66,7 +66,7 @@ export const computeEmptyDraftValue = ({ } throw new CustomError( - `Record field type not supported : ${fieldDefinition.type}}`, + `Record field type not supported : ${fieldDefinition.type}`, 'RECORD_FIELD_TYPE_NOT_SUPPORTED', ); };