fix: add RICH_TEXT to FIELD_NOT_OVERWRITTEN_AT_DRAFT to prevent table cell crash
https://sonarly.com/issue/6010?type=bug Pressing any key while focused on a RICH_TEXT table cell (e.g., Notes body field) throws an unhandled error because `computeDraftValueFromString` has no handler for the RICH_TEXT field type. Fix: **Two changes, both 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 handles all types via the existing record value) 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}` ``.
This commit is contained in:
+1
@@ -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,
|
||||
];
|
||||
|
||||
+1
-1
@@ -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',
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user