mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-06-30 12:05:14 +08:00
fix: web app form<RunOnce> component is changing an uncontrolled inpu… (#17269)
This commit is contained in:
parent
e58703877b
commit
2ae7a70be9
@ -1,4 +1,5 @@
|
|||||||
import type { FC, FormEvent } from 'react'
|
import type { FC, FormEvent } from 'react'
|
||||||
|
import { useEffect } from 'react'
|
||||||
import React, { useCallback } from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import {
|
import {
|
||||||
@ -59,6 +60,17 @@ const RunOnce: FC<IRunOnceProps> = ({
|
|||||||
inputsRef.current = newInputs
|
inputsRef.current = newInputs
|
||||||
}, [onInputsChange, inputsRef])
|
}, [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 (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
<section>
|
<section>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user