Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: When var value changed, PromptEditor should be reset (#22219)

yolofit0dee41c07447
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 775f232fd06..eabc10b1687 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
@@ -25,6 +25,7 @@ import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../../cons
import ConditionWrap from '../condition-wrap'
import ConditionOperator from './condition-operator'
import ConditionInput from './condition-input'
+import { useWorkflowStore } from '@/app/components/workflow/store'
import ConditionVarSelector from './condition-var-selector'
import type {
@@ -88,6 +89,11 @@ const ConditionItem = ({
const [isHovered, setIsHovered] = useState(false)
const [open, setOpen] = useState(false)
+ const workflowStore = useWorkflowStore()
+ const {
+ setControlPromptEditorRerenderKey,
+ } = workflowStore.getState()
+
const doUpdateCondition = useCallback((newCondition: Condition) => {
if (isSubVariableKey)
onUpdateSubVariableCondition?.(caseId, conditionId, condition.id, newCondition)
@@ -208,10 +214,11 @@ const ConditionItem = ({
draft.varType = resolvedVarType
draft.value = ''
draft.comparison_operator = getOperators(resolvedVarType)[0]
+ setTimeout(() => setControlPromptEditorRerenderKey(Date.now()))
})
doUpdateCondition(newCondition)
setOpen(false)
- }, [condition, doUpdateCondition, availableNodes, isChatMode])
+ }, [condition, doUpdateCondition, availableNodes, isChatMode, setControlPromptEditorRerenderKey])
return (
<div className={cn('mb-1 flex last-of-type:mb-0', className)}>