From 78da4ca024c19ac98f98bd153eb66a952b62dadb Mon Sep 17 00:00:00 2001 From: KVOJJJin Date: Fri, 11 Apr 2025 14:40:57 +0800 Subject: [PATCH] fix: do not submit value when file input is optional (#17861) --- .../share/text-generation/run-once/index.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 e413bd53ac..721dbb42c3 100644 --- a/web/app/components/share/text-generation/run-once/index.tsx +++ b/web/app/components/share/text-generation/run-once/index.tsx @@ -45,7 +45,10 @@ const RunOnce: FC = ({ const onClear = () => { const newInputs: Record = {} promptConfig.prompt_variables.forEach((item) => { - newInputs[item.key] = '' + if (item.type === 'text-input' || item.type === 'paragraph') + newInputs[item.key] = '' + else + newInputs[item.key] = undefined }) onInputsChange(newInputs) } @@ -63,7 +66,10 @@ const RunOnce: FC = ({ useEffect(() => { const newInputs: Record = {} promptConfig.prompt_variables.forEach((item) => { - newInputs[item.key] = '' + if (item.type === 'text-input' || item.type === 'paragraph') + newInputs[item.key] = '' + else + newInputs[item.key] = undefined }) onInputsChange(newInputs) }, [promptConfig.prompt_variables, onInputsChange])