diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx index ef94f7c82..775f232fd 100644 --- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx +++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx @@ -37,6 +37,8 @@ import { VarType } from '@/app/components/workflow/types' import cn from '@/utils/classnames' import { SimpleSelect as Select } from '@/app/components/base/select' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' +import { getVarType } from '@/app/components/workflow/nodes/_base/components/variable/utils' +import { useIsChatMode } from '@/app/components/workflow/hooks/use-workflow' const optionNameI18NPrefix = 'workflow.nodes.ifElse.optionName' type ConditionItemProps = { @@ -82,7 +84,7 @@ const ConditionItem = ({ filterVar, }: ConditionItemProps) => { const { t } = useTranslation() - + const isChatMode = useIsChatMode() const [isHovered, setIsHovered] = useState(false) const [open, setOpen] = useState(false) @@ -120,6 +122,7 @@ const ConditionItem = ({ }, [condition, doUpdateCondition]) const isSubVariable = condition.varType === VarType.arrayFile && [ComparisonOperator.contains, ComparisonOperator.notContains, ComparisonOperator.allOf].includes(condition.comparison_operator!) + const fileAttr = useMemo(() => { if (file) return file @@ -194,15 +197,21 @@ const ConditionItem = ({ }, [caseId, condition, conditionId, isSubVariableKey, onRemoveCondition, onRemoveSubVariableCondition]) const handleVarChange = useCallback((valueSelector: ValueSelector, varItem: Var) => { + const resolvedVarType = getVarType({ + valueSelector, + availableNodes, + isChatMode, + }) + const newCondition = produce(condition, (draft) => { draft.variable_selector = valueSelector - draft.varType = varItem.type + draft.varType = resolvedVarType draft.value = '' - draft.comparison_operator = getOperators(varItem.type)[0] + draft.comparison_operator = getOperators(resolvedVarType)[0] }) doUpdateCondition(newCondition) setOpen(false) - }, [condition, doUpdateCondition]) + }, [condition, doUpdateCondition, availableNodes, isChatMode]) return (