Browse Source

fix: web app form<RunOnce> component is changing an uncontrolled inpu… (#17269)

tags/1.2.0
NFish 7 months ago
parent
commit
2ae7a70be9
No account linked to committer's email address
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      web/app/components/share/text-generation/run-once/index.tsx

+ 12
- 0
web/app/components/share/text-generation/run-once/index.tsx View File

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 {
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…
Cancel
Save