fix(twenty-front): add RICH_TEXT to FIELD_NOT_OVERWRITTEN_AT_DRAFT to prevent table cell crash

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).
This commit is contained in:
Sonarly Claude Code
2026-05-04 06:13:02 +00:00
parent 5bf7e8b101
commit 831b2c4a39
3 changed files with 3 additions and 2 deletions
@@ -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,
];
@@ -83,7 +83,7 @@ export const computeDraftValueFromString = <FieldValue>({
}
throw new CustomError(
`Record field type not supported : ${fieldDefinition.type}}`,
`Record field type not supported : ${fieldDefinition.type}`,
'RECORD_FIELD_TYPE_NOT_SUPPORTED',
);
};
@@ -66,7 +66,7 @@ export const computeEmptyDraftValue = <FieldValue>({
}
throw new CustomError(
`Record field type not supported : ${fieldDefinition.type}}`,
`Record field type not supported : ${fieldDefinition.type}`,
'RECORD_FIELD_TYPE_NOT_SUPPORTED',
);
};