Skip to content

Commit

Permalink
fix(RunOnce): change to form submission instead of onKeyDown and onClick
Browse files Browse the repository at this point in the history
  • Loading branch information
MH4GF committed Sep 15, 2024
1 parent bf16de5 commit 544d209
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions web/app/components/share/text-generation/run-once/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FC } from 'react'
import type { FC, FormEvent } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next'
import {
Expand Down Expand Up @@ -39,11 +39,16 @@ const RunOnce: FC<IRunOnceProps> = ({
onInputsChange(newInputs)
}

const onSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault()
onSend()
}

return (
<div className="">
<section>
{/* input form */}
<form>
<form onSubmit={onSubmit}>
{promptConfig.prompt_variables.map(item => (
<div className='w-full mt-4' key={item.key}>
<label className='text-gray-900 text-sm font-medium'>{item.name}</label>
Expand All @@ -65,12 +70,6 @@ const RunOnce: FC<IRunOnceProps> = ({
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
value={inputs[item.key]}
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault()
onSend()
}
}}
maxLength={item.max_length || DEFAULT_VALUE_MAX_LEN}
/>
)}
Expand Down Expand Up @@ -124,8 +123,8 @@ const RunOnce: FC<IRunOnceProps> = ({
<span className='text-[13px]'>{t('common.operation.clear')}</span>
</Button>
<Button
type='submit'
variant="primary"
onClick={onSend}
disabled={false}
>
<PlayIcon className="shrink-0 w-4 h-4 mr-1" aria-hidden="true" />
Expand Down

0 comments on commit 544d209

Please sign in to comment.