diff --git a/web/app/components/workflow/nodes/http/panel.tsx b/web/app/components/workflow/nodes/http/panel.tsx index 4401d6a790..646ccc96d2 100644 --- a/web/app/components/workflow/nodes/http/panel.tsx +++ b/web/app/components/workflow/nodes/http/panel.tsx @@ -27,6 +27,7 @@ const Panel: FC> = ({ const { readOnly, + isDataReady, inputs, handleMethodChange, handleUrlChange, @@ -53,6 +54,9 @@ const Panel: FC> = ({ setInputVarValues, runResult, } = useConfig(id, data) + // To prevent prompt editor in body not update data. + if (!isDataReady) + return null return (
diff --git a/web/app/components/workflow/nodes/http/use-config.ts b/web/app/components/workflow/nodes/http/use-config.ts index 36293f607e..d49f199bb7 100644 --- a/web/app/components/workflow/nodes/http/use-config.ts +++ b/web/app/components/workflow/nodes/http/use-config.ts @@ -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,