From 6607fe05041bd0764936a22789c9b91e79aead08 Mon Sep 17 00:00:00 2001 From: martmull Date: Thu, 20 Nov 2025 12:11:16 +0100 Subject: [PATCH] Fix wrong empty string formatting (#15949) As title, solves this kind of issues https://twentyfortwenty.twenty.com/object/workflowRun/d6aca50e-68ba-4715-8835-ea22bd44fb88 Solves null currencyDisplay when null currencyCode and null amountMicros ### Before image ### After image --- .../display/components/CurrencyDisplay.tsx | 6 ------ .../src/utils/variable-resolver.test.ts | 19 +++++++++++++++++++ .../src/utils/variable-resolver.ts | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/packages/twenty-front/src/modules/ui/field/display/components/CurrencyDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/CurrencyDisplay.tsx index 25c5a27cf7..9c554fdfc1 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/CurrencyDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/CurrencyDisplay.tsx @@ -23,8 +23,6 @@ export const CurrencyDisplay = ({ }: CurrencyDisplayProps) => { const theme = useTheme(); - const shouldDisplayCurrency = isDefined(currencyValue?.currencyCode); - const CurrencyIcon = isDefined(currencyValue?.currencyCode) ? SETTINGS_FIELD_CURRENCY_CODES[currencyValue?.currencyCode]?.Icon : null; @@ -36,10 +34,6 @@ export const CurrencyDisplay = ({ const format = fieldDefinition.metadata.settings?.format; const { formatNumber } = useNumberFormat(); - if (!shouldDisplayCurrency) { - return {0}; - } - return ( {isDefined(CurrencyIcon) && amountToDisplay !== null && ( diff --git a/packages/twenty-shared/src/utils/variable-resolver.test.ts b/packages/twenty-shared/src/utils/variable-resolver.test.ts index d629cca6fe..377f1d1f72 100644 --- a/packages/twenty-shared/src/utils/variable-resolver.test.ts +++ b/packages/twenty-shared/src/utils/variable-resolver.test.ts @@ -10,12 +10,31 @@ describe('resolveInput', () => { theme: 'dark', notifications: true, }, + specialValues: { + nullValue: null, + undefinedValue: undefined, + emptyString: '', + zero: 0, + booleanFalse: false, + booleanTrue: true, + }, }; it('should return null for null input', () => { expect(resolveInput(null, context)).toBeNull(); }); + it('should support special values', () => { + expect(resolveInput('{{specialValues.nullValue}}', context)).toBeNull(); + expect( + resolveInput('{{specialValues.undefinedValue}}', context), + ).toBeUndefined(); + expect(resolveInput('{{specialValues.emptyString}}', context)).toBe(''); + expect(resolveInput('{{specialValues.zero}}', context)).toBe(0); + expect(resolveInput('{{specialValues.booleanFalse}}', context)).toBe(false); + expect(resolveInput('{{specialValues.booleanTrue}}', context)).toBe(true); + }); + it('should return undefined for undefined input', () => { expect(resolveInput(undefined, context)).toBeUndefined(); }); diff --git a/packages/twenty-shared/src/utils/variable-resolver.ts b/packages/twenty-shared/src/utils/variable-resolver.ts index 6116da9635..92e5bcb208 100644 --- a/packages/twenty-shared/src/utils/variable-resolver.ts +++ b/packages/twenty-shared/src/utils/variable-resolver.ts @@ -99,7 +99,7 @@ const evalFromContext = (input: string, context: Record) => { }, }); - return JSON.parse(inferredInput) ?? ''; + return JSON.parse(inferredInput); } catch { return undefined; }