mirror of https://github.com/langgenius/dify.git
fix: prompt editor not update data
This commit is contained in:
parent
dae62bef78
commit
76a07513ba
|
|
@ -27,6 +27,7 @@ const Panel: FC<NodePanelProps<HttpNodeType>> = ({
|
|||
|
||||
const {
|
||||
readOnly,
|
||||
isDataReady,
|
||||
inputs,
|
||||
handleMethodChange,
|
||||
handleUrlChange,
|
||||
|
|
@ -53,6 +54,9 @@ const Panel: FC<NodePanelProps<HttpNodeType>> = ({
|
|||
setInputVarValues,
|
||||
runResult,
|
||||
} = useConfig(id, data)
|
||||
// To prevent prompt editor in body not update data.
|
||||
if (!isDataReady)
|
||||
return null
|
||||
|
||||
return (
|
||||
<div className='mt-2'>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useEffect } from 'react'
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import produce from 'immer'
|
||||
import { useBoolean } from 'ahooks'
|
||||
import useVarList from '../_base/hooks/use-var-list'
|
||||
|
|
@ -26,6 +26,8 @@ const useConfig = (id: string, payload: HttpNodeType) => {
|
|||
setInputs,
|
||||
})
|
||||
|
||||
const [isDataReady, setIsDataReady] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const isReady = defaultConfig && Object.keys(defaultConfig).length > 0
|
||||
if (isReady) {
|
||||
|
|
@ -38,6 +40,7 @@ const useConfig = (id: string, payload: HttpNodeType) => {
|
|||
newInputs.body.data = transformToBodyPayload(bodyData, [BodyType.formData, BodyType.xWwwFormUrlencoded].includes(newInputs.body.type))
|
||||
|
||||
setInputs(newInputs)
|
||||
setIsDataReady(true)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [defaultConfig])
|
||||
|
|
@ -151,6 +154,7 @@ const useConfig = (id: string, payload: HttpNodeType) => {
|
|||
|
||||
return {
|
||||
readOnly,
|
||||
isDataReady,
|
||||
inputs,
|
||||
handleVarListChange,
|
||||
handleAddVariable,
|
||||
|
|
|
|||
Loading…
Reference in New Issue