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: web app form<RunOnce> component is changing an uncontrolled inpu… (#17269)

NFish2ae7a70be918
diff --git a/web/app/components/share/text-generation/run-once/index.tsx b/web/app/components/share/text-generation/run-once/index.tsx
index dbaf8e026e3..f31c5d5e859 100644
--- a/web/app/components/share/text-generation/run-once/index.tsx
+++ b/web/app/components/share/text-generation/run-once/index.tsx
@@ -1,4 +1,5 @@
import type { FC, FormEvent } from 'react'
+import { useEffect } from 'react'
import React, { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import {
@@ -59,6 +60,17 @@ const RunOnce: FC<IRunOnceProps> = ({
inputsRef.current = newInputs
}, [onInputsChange, inputsRef])
+ useEffect(() => {
+ const newInputs: Record<string, any> = {}
+ promptConfig.prompt_variables.forEach((item) => {
+ newInputs[item.key] = ''
+ })
+ onInputsChange(newInputs)
+ }, [promptConfig.prompt_variables])
+
+ if (inputs === null || inputs === undefined || Object.keys(inputs).length === 0)
+ return null
+
return (
<div className="">
<section>