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