Skip to content

Commit d641bdf

Browse files
committed
Merge remote-tracking branch 'github/sf-site-migration/ui' into feat/1.1.1/user-center
2 parents 7721946 + 09e4ee1 commit d641bdf

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

ui/src/components/SchemaForm/index.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
ForwardRefRenderFunction,
33
forwardRef,
44
useImperativeHandle,
5+
useEffect,
56
} from 'react';
67
import { Form, Button, Stack } from 'react-bootstrap';
78
import { useTranslation } from 'react-i18next';
@@ -155,16 +156,10 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
155156
*/
156157
const setDefaultValueAsDomBehaviour = () => {
157158
keys.forEach((k) => {
158-
const formVal = formData[k]?.value;
159+
const fieldVal = formData[k]?.value;
159160
const metaProp = properties[k];
160161
const uiCtrl = uiSchema[k]?.['ui:widget'];
161-
if (
162-
!metaProp ||
163-
!uiCtrl ||
164-
formVal ||
165-
formVal === 0 ||
166-
formVal === false
167-
) {
162+
if (!metaProp || !uiCtrl || fieldVal !== undefined) {
168163
return;
169164
}
170165
if (uiCtrl === 'select' && metaProp.enum?.[0] !== undefined) {
@@ -176,7 +171,9 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
176171
}
177172
});
178173
};
179-
setDefaultValueAsDomBehaviour();
174+
useEffect(() => {
175+
setDefaultValueAsDomBehaviour();
176+
}, [formData]);
180177

181178
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
182179
const { name, value } = e.target;

ui/src/pages/Admin/Smtp/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const Smtp: FC = () => {
3333
description: t('smtp_host.text'),
3434
},
3535
encryption: {
36-
type: 'boolean',
36+
type: 'string',
3737
title: t('encryption.label'),
3838
description: t('encryption.text'),
3939
enum: ['SSL', ''],
@@ -179,7 +179,7 @@ const Smtp: FC = () => {
179179
}, [setting]);
180180

181181
useEffect(() => {
182-
if (formData.smtp_authentication.value === '') {
182+
if (!/true|false/.test(formData.smtp_authentication.value)) {
183183
return;
184184
}
185185
if (formData.smtp_authentication.value) {

0 commit comments

Comments
 (0)