diff --git a/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx b/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx index 5d032b06d9..13d9d7ca04 100644 --- a/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx +++ b/web/app/components/base/prompt-editor/plugins/hitl-input-block/input-field.tsx @@ -30,7 +30,7 @@ const InputField: React.FC = ({ const handleSave = useCallback(() => { onChange(tempPayload) }, [tempPayload]) - const placeholderConfig = payload.placeholder + const placeholderConfig = tempPayload.placeholder const handlePlaceholderChange = useCallback((key: keyof FormInputItemPlaceholder) => { return (value: any) => { const nextValue = produce(tempPayload, (draft) => { @@ -40,7 +40,7 @@ const InputField: React.FC = ({ }) setTempPayload(nextValue) } - }, []) + }, [tempPayload]) return (
{t(`${i18nPrefix}.title`)}
@@ -58,16 +58,9 @@ const InputField: React.FC = ({ />
-
+
{t(`${i18nPrefix}.prePopulateField`)}
- {/* { - setTempPayload(prev => ({ ...prev, placeholder: { ...(prev.placeholder || {}), value: e.target.value } } as any)) - }} - /> */} { diff --git a/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx b/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx index 22e09a8b1a..0ba7bbe60d 100644 --- a/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx +++ b/web/app/components/base/prompt-editor/plugins/hitl-input-block/pre-populate.tsx @@ -6,8 +6,8 @@ import React, { useCallback, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import Textarea from '../../../textarea' import TagLabel from './tag-label' +import TypeSwitch from './type-switch' import cn from '@/utils/classnames' -import { Variable02 } from '../../../icons/src/vender/solid/development' type Props = { isVariable?: boolean @@ -52,21 +52,21 @@ const PrePopulate: FC = ({ value, onValueChange, }) => { - const { t } = useTranslation() - const [onPlaceholderClicked, setOnPlaceholderClicked] = useState(false) const handlePlaceholderTypeClick = useCallback((isVar: boolean) => { setOnPlaceholderClicked(true) onIsVariableChange?.(isVar) }, [onIsVariableChange]) + const [isFocus, setIsFocus] = useState(false) + const isShowPlaceholder = !onPlaceholderClicked && (isVariable ? (!valueSelector || valueSelector.length === 0) : !value) if (isShowPlaceholder) return - const main = (() => { - if (isVariable) { - return ( + if (isVariable) { + return ( +
= ({ readonly={false} zIndex={1000} /> - ) - } - return ( + +
+ ) + } + return ( +