File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 2
2
ForwardRefRenderFunction ,
3
3
forwardRef ,
4
4
useImperativeHandle ,
5
+ useEffect ,
5
6
} from 'react' ;
6
7
import { Form , Button , Stack } from 'react-bootstrap' ;
7
8
import { useTranslation } from 'react-i18next' ;
@@ -155,16 +156,10 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
155
156
*/
156
157
const setDefaultValueAsDomBehaviour = ( ) => {
157
158
keys . forEach ( ( k ) => {
158
- const formVal = formData [ k ] ?. value ;
159
+ const fieldVal = formData [ k ] ?. value ;
159
160
const metaProp = properties [ k ] ;
160
161
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 ) {
168
163
return ;
169
164
}
170
165
if ( uiCtrl === 'select' && metaProp . enum ?. [ 0 ] !== undefined ) {
@@ -176,7 +171,9 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
176
171
}
177
172
} ) ;
178
173
} ;
179
- setDefaultValueAsDomBehaviour ( ) ;
174
+ useEffect ( ( ) => {
175
+ setDefaultValueAsDomBehaviour ( ) ;
176
+ } , [ formData ] ) ;
180
177
181
178
const handleInputChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
182
179
const { name, value } = e . target ;
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ const Smtp: FC = () => {
33
33
description : t ( 'smtp_host.text' ) ,
34
34
} ,
35
35
encryption : {
36
- type : 'boolean ' ,
36
+ type : 'string ' ,
37
37
title : t ( 'encryption.label' ) ,
38
38
description : t ( 'encryption.text' ) ,
39
39
enum : [ 'SSL' , '' ] ,
@@ -179,7 +179,7 @@ const Smtp: FC = () => {
179
179
} , [ setting ] ) ;
180
180
181
181
useEffect ( ( ) => {
182
- if ( formData . smtp_authentication . value === '' ) {
182
+ if ( ! / t r u e | f a l s e / . test ( formData . smtp_authentication . value ) ) {
183
183
return ;
184
184
}
185
185
if ( formData . smtp_authentication . value ) {
You can’t perform that action at this time.
0 commit comments