fix: When var value changed, PromptEditor should be reset (#22219)
This commit is contained in:
@@ -25,6 +25,7 @@ import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../../cons
|
|||||||
import ConditionWrap from '../condition-wrap'
|
import ConditionWrap from '../condition-wrap'
|
||||||
import ConditionOperator from './condition-operator'
|
import ConditionOperator from './condition-operator'
|
||||||
import ConditionInput from './condition-input'
|
import ConditionInput from './condition-input'
|
||||||
|
import { useWorkflowStore } from '@/app/components/workflow/store'
|
||||||
|
|
||||||
import ConditionVarSelector from './condition-var-selector'
|
import ConditionVarSelector from './condition-var-selector'
|
||||||
import type {
|
import type {
|
||||||
@@ -88,6 +89,11 @@ const ConditionItem = ({
|
|||||||
const [isHovered, setIsHovered] = useState(false)
|
const [isHovered, setIsHovered] = useState(false)
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
|
const workflowStore = useWorkflowStore()
|
||||||
|
const {
|
||||||
|
setControlPromptEditorRerenderKey,
|
||||||
|
} = workflowStore.getState()
|
||||||
|
|
||||||
const doUpdateCondition = useCallback((newCondition: Condition) => {
|
const doUpdateCondition = useCallback((newCondition: Condition) => {
|
||||||
if (isSubVariableKey)
|
if (isSubVariableKey)
|
||||||
onUpdateSubVariableCondition?.(caseId, conditionId, condition.id, newCondition)
|
onUpdateSubVariableCondition?.(caseId, conditionId, condition.id, newCondition)
|
||||||
@@ -208,10 +214,11 @@ const ConditionItem = ({
|
|||||||
draft.varType = resolvedVarType
|
draft.varType = resolvedVarType
|
||||||
draft.value = ''
|
draft.value = ''
|
||||||
draft.comparison_operator = getOperators(resolvedVarType)[0]
|
draft.comparison_operator = getOperators(resolvedVarType)[0]
|
||||||
|
setTimeout(() => setControlPromptEditorRerenderKey(Date.now()))
|
||||||
})
|
})
|
||||||
doUpdateCondition(newCondition)
|
doUpdateCondition(newCondition)
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
}, [condition, doUpdateCondition, availableNodes, isChatMode])
|
}, [condition, doUpdateCondition, availableNodes, isChatMode, setControlPromptEditorRerenderKey])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn('mb-1 flex last-of-type:mb-0', className)}>
|
<div className={cn('mb-1 flex last-of-type:mb-0', className)}>
|
||||||
|
Reference in New Issue
Block a user