From d4f976270d53d36b6972bdf682e87a85cb3a57a0 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 19 Aug 2025 16:16:10 +0800 Subject: [PATCH] fix: chore: if boolean array bug --- web/app/components/workflow/nodes/if-else/default.ts | 4 ++-- web/app/components/workflow/nodes/if-else/node.tsx | 7 ++----- web/app/components/workflow/nodes/if-else/use-config.ts | 2 +- .../components/workflow/nodes/list-operator/use-config.ts | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/web/app/components/workflow/nodes/if-else/default.ts b/web/app/components/workflow/nodes/if-else/default.ts index b8c88ed990..000e4d9f62 100644 --- a/web/app/components/workflow/nodes/if-else/default.ts +++ b/web/app/components/workflow/nodes/if-else/default.ts @@ -58,13 +58,13 @@ const nodeDefault: NodeDefault = { if (isEmptyRelatedOperator(c.comparison_operator!)) return true - return !!c.value + return (c.varType === VarType.boolean || c.varType === VarType.arrayBoolean) ? c.value === undefined : !!c.value }) if (!isSet) errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t(`${i18nPrefix}.fields.variableValue`) }) } else { - if (!isEmptyRelatedOperator(condition.comparison_operator!) && (condition.varType === VarType.boolean ? condition.value === undefined : !condition.value)) + if (!isEmptyRelatedOperator(condition.comparison_operator!) && ((condition.varType === VarType.boolean || condition.varType === VarType.arrayBoolean) ? condition.value === undefined : !condition.value)) errorMessages = t(`${i18nPrefix}.fieldRequired`, { field: t(`${i18nPrefix}.fields.variableValue`) }) } } diff --git a/web/app/components/workflow/nodes/if-else/node.tsx b/web/app/components/workflow/nodes/if-else/node.tsx index 7cd62043ff..e423e95a3f 100644 --- a/web/app/components/workflow/nodes/if-else/node.tsx +++ b/web/app/components/workflow/nodes/if-else/node.tsx @@ -24,17 +24,14 @@ const IfElseNode: FC> = (props) => { if (!c.comparison_operator) return false - if (isEmptyRelatedOperator(c.comparison_operator!)) - return true - - return c.varType === VarType.boolean ? true : !!c.value + return (c.varType === VarType.boolean || c.varType === VarType.arrayBoolean) ? true : !!c.value }) return isSet } else { if (isEmptyRelatedOperator(condition.comparison_operator!)) return true - return condition.varType === VarType.boolean ? true : !!condition.value + return (condition.varType === VarType.boolean || condition.varType === VarType.arrayBoolean) ? true : !!condition.value } }, []) const conditionNotSet = (
diff --git a/web/app/components/workflow/nodes/if-else/use-config.ts b/web/app/components/workflow/nodes/if-else/use-config.ts index 3fbc3f1a5f..f88c119614 100644 --- a/web/app/components/workflow/nodes/if-else/use-config.ts +++ b/web/app/components/workflow/nodes/if-else/use-config.ts @@ -144,7 +144,7 @@ const useConfig = (id: string, payload: IfElseNodeType) => { varType: varItem.type, variable_selector: valueSelector, comparison_operator: getOperators(varItem.type, getIsVarFileAttribute(valueSelector) ? { key: valueSelector.slice(-1)[0] } : undefined)[0], - value: varItem.type === VarType.boolean ? false : '', + value: (varItem.type === VarType.boolean || varItem.type === VarType.arrayBoolean) ? false : '', }) } }) diff --git a/web/app/components/workflow/nodes/list-operator/use-config.ts b/web/app/components/workflow/nodes/list-operator/use-config.ts index ac137c8cf2..d53a0a6c3a 100644 --- a/web/app/components/workflow/nodes/list-operator/use-config.ts +++ b/web/app/components/workflow/nodes/list-operator/use-config.ts @@ -45,7 +45,7 @@ const useConfig = (id: string, payload: ListFilterNodeType) => { isChatMode, isConstant: false, }) - let itemVarType = varType + let itemVarType switch (varType) { case VarType.arrayNumber: itemVarType = VarType.number