From a4d511eb3e67c9be7de12a8edfd7bffb88fb5608 Mon Sep 17 00:00:00 2001 From: Manh Hung Nguyen Date: Wed, 29 Nov 2023 14:36:19 +0700 Subject: [PATCH] Check statisfied condition should return false when value is undefined Fixes: AFORM-3738 --- .../formDependConditions.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/@optimizely/forms-sdk/src/form-depend-conditions/formDependConditions.ts b/src/@optimizely/forms-sdk/src/form-depend-conditions/formDependConditions.ts index 401041c..f5192be 100644 --- a/src/@optimizely/forms-sdk/src/form-depend-conditions/formDependConditions.ts +++ b/src/@optimizely/forms-sdk/src/form-depend-conditions/formDependConditions.ts @@ -24,16 +24,14 @@ export class FormDependConditions { for (let i = 0; i < conditionProps.conditions.length; i++) { const condition = conditionProps.conditions[i] const fieldValue = formSubmissions.filter(s => equals(s.elementKey, condition.field))[0]?.value as string - if (!isNull(fieldValue)) { - const conditionFunction = ConditionFunctions[condition.operator]; - if (!isNull(conditionFunction)){ - var checkResult = conditionFunction(fieldValue, condition.fieldValue) - if (conditionProps.conditionCombination === ConditionCombinationType.Any && checkResult) { - return true - } - if (conditionProps.conditionCombination !== ConditionCombinationType.Any && !checkResult) { - return false - } + const conditionFunction = ConditionFunctions[condition.operator]; + if (!isNull(conditionFunction)){ + let checkResult = conditionFunction(fieldValue, condition.fieldValue) + if (conditionProps.conditionCombination === ConditionCombinationType.Any && checkResult) { + return true + } + if (conditionProps.conditionCombination !== ConditionCombinationType.Any && !checkResult) { + return false } } }