diff --git a/web/app/components/base/markdown-blocks/form.tsx b/web/app/components/base/markdown-blocks/form.tsx index ab7e7cef53..02bd765a1d 100644 --- a/web/app/components/base/markdown-blocks/form.tsx +++ b/web/app/components/base/markdown-blocks/form.tsx @@ -28,6 +28,7 @@ enum SUPPORTED_TYPES { DATETIME = 'datetime', CHECKBOX = 'checkbox', SELECT = 'select', + HIDDEN = 'hidden', } const MarkdownForm = ({ node }: any) => { const { onSend } = useChatContext() @@ -37,8 +38,14 @@ const MarkdownForm = ({ node }: any) => { useEffect(() => { const initialValues: { [key: string]: any } = {} node.children.forEach((child: any) => { - if ([SUPPORTED_TAGS.INPUT, SUPPORTED_TAGS.TEXTAREA].includes(child.tagName)) - initialValues[child.properties.name] = child.properties.value + if ([SUPPORTED_TAGS.INPUT, SUPPORTED_TAGS.TEXTAREA].includes(child.tagName)) { + // Always set initial value for hidden inputs + if (child.tagName === SUPPORTED_TAGS.INPUT && child.properties.type === SUPPORTED_TYPES.HIDDEN) { + initialValues[child.properties.name] = child.properties.value || '' + } else { + initialValues[child.properties.name] = child.properties.value + } + } }) setFormValues(initialValues) }, [node.children]) @@ -180,6 +187,19 @@ const MarkdownForm = ({ node }: any) => { ) } + if (child.properties.type === SUPPORTED_TYPES.HIDDEN) { + // Hidden input is not displayed but maintains form value + return ( + + ) + } + return (