diff --git a/packages/twenty-front/src/modules/workflow/search-variables/utils/__tests__/parseEditorContent.test.ts b/packages/twenty-front/src/modules/workflow/search-variables/utils/__tests__/parseEditorContent.test.ts index 1302ebb04..537530d23 100644 --- a/packages/twenty-front/src/modules/workflow/search-variables/utils/__tests__/parseEditorContent.test.ts +++ b/packages/twenty-front/src/modules/workflow/search-variables/utils/__tests__/parseEditorContent.test.ts @@ -267,4 +267,33 @@ describe('parseEditorContent', () => { expect(parseEditorContent(input)).toBe('First line\nSecond line'); }); + + it('should handle spaces between variables correctly', () => { + const input: JSONContent = { + type: 'doc', + content: [ + { + type: 'paragraph', + content: [ + { + type: 'variableTag', + attrs: { variable: '{{user.firstName}}' }, + }, + { + type: 'text', + text: '\u00A0', // NBSP character + }, + { + type: 'variableTag', + attrs: { variable: '{{user.lastName}}' }, + }, + ], + }, + ], + }; + + expect(parseEditorContent(input)).toBe( + '{{user.firstName}} {{user.lastName}}', + ); + }); }); diff --git a/packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts b/packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts index ebad7f0e9..c27e655d0 100644 --- a/packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts +++ b/packages/twenty-front/src/modules/workflow/search-variables/utils/parseEditorContent.ts @@ -11,7 +11,8 @@ export const parseEditorContent = (json: JSONContent): string => { } if (node.type === 'text') { - return node.text || ''; + // Replace   with regular space + return node?.text?.replace(/\u00A0/g, ' ') ?? ''; } if (node.type === 'hardBreak') {