diff --git a/ui/src/components/SchemaForm/index.tsx b/ui/src/components/SchemaForm/index.tsx index 0dc5e209..c57ca5b2 100644 --- a/ui/src/components/SchemaForm/index.tsx +++ b/ui/src/components/SchemaForm/index.tsx @@ -2,6 +2,7 @@ import { ForwardRefRenderFunction, forwardRef, useImperativeHandle, + useEffect, } from 'react'; import { Form, Button, Stack } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; @@ -155,16 +156,10 @@ const SchemaForm: ForwardRefRenderFunction = ( */ const setDefaultValueAsDomBehaviour = () => { keys.forEach((k) => { - const formVal = formData[k]?.value; + const fieldVal = formData[k]?.value; const metaProp = properties[k]; const uiCtrl = uiSchema[k]?.['ui:widget']; - if ( - !metaProp || - !uiCtrl || - formVal || - formVal === 0 || - formVal === false - ) { + if (!metaProp || !uiCtrl || fieldVal !== undefined) { return; } if (uiCtrl === 'select' && metaProp.enum?.[0] !== undefined) { @@ -176,7 +171,9 @@ const SchemaForm: ForwardRefRenderFunction = ( } }); }; - setDefaultValueAsDomBehaviour(); + useEffect(() => { + setDefaultValueAsDomBehaviour(); + }, [formData]); const handleInputChange = (e: React.ChangeEvent) => { const { name, value } = e.target; diff --git a/ui/src/pages/Admin/Smtp/index.tsx b/ui/src/pages/Admin/Smtp/index.tsx index 3a625157..135862ae 100644 --- a/ui/src/pages/Admin/Smtp/index.tsx +++ b/ui/src/pages/Admin/Smtp/index.tsx @@ -33,7 +33,7 @@ const Smtp: FC = () => { description: t('smtp_host.text'), }, encryption: { - type: 'boolean', + type: 'string', title: t('encryption.label'), description: t('encryption.text'), enum: ['SSL', ''], @@ -179,7 +179,7 @@ const Smtp: FC = () => { }, [setting]); useEffect(() => { - if (formData.smtp_authentication.value === '') { + if (!/true|false/.test(formData.smtp_authentication.value)) { return; } if (formData.smtp_authentication.value) {