@@ -208,17 +208,13 @@ const FormBaseComp = (function () {
208
208
) ;
209
209
} )
210
210
. setPropertyViewFn ( ( children ) => {
211
- const editorContext = useContext ( EditorContext ) ;
212
- const isLogicMode = editorContext . editorModeStatus === "logic" || editorContext . editorModeStatus === "both" ;
213
- const isLayoutMode = editorContext . editorModeStatus === "layout" || editorContext . editorModeStatus === "both" ;
214
-
215
211
return (
216
212
< >
217
213
< Section name = { sectionNames . basic } >
218
214
{ children . resetAfterSubmit . propertyView ( { label :trans ( "formComp.resetAfterSubmit" ) } ) }
219
215
</ Section >
220
216
221
- { isLogicMode && (
217
+ { ( useContext ( EditorContext ) . editorModeStatus === "logic" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
222
218
< > < Section name = { sectionNames . interaction } >
223
219
{ children . onEvent . getPropertyView ( ) }
224
220
{ disabledPropertyView ( children ) }
@@ -229,22 +225,22 @@ const FormBaseComp = (function () {
229
225
</ >
230
226
) }
231
227
232
- { isLayoutMode && (
228
+ { ( useContext ( EditorContext ) . editorModeStatus === "layout" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
233
229
< >
234
230
< Section name = { sectionNames . layout } >
235
231
{ children . container . getPropertyView ( ) }
236
232
</ Section >
237
233
</ >
238
234
) }
239
235
240
- { isLogicMode && (
236
+ { ( useContext ( EditorContext ) . editorModeStatus === "logic" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
241
237
< Section name = { sectionNames . advanced } >
242
238
{ children . initialData . propertyView ( { label :trans ( "formComp.initialData" ) } ) }
243
239
{ children . invalidFormMessage . propertyView ( { label :trans ( "formComp.invalidFormMessage" ) } ) }
244
240
</ Section >
245
241
) }
246
242
247
- { isLayoutMode && (
243
+ { ( useContext ( EditorContext ) . editorModeStatus === "layout" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
248
244
< >
249
245
< Section name = { sectionNames . style } >
250
246
{ children . container . stylePropertyView ( ) }
@@ -289,7 +285,8 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
289
285
}
290
286
traverseFormItems ( consumer :( item :GridItemComp ) => boolean ) {
291
287
return traverseCompTree ( this . getCompTree ( ) , ( item ) => {
292
- return item . children . comp . children . formDataKey ?consumer ( item as GridItemComp ) :true ;
288
+ const hasFormDataKey = item . children . comp . children . hasOwnProperty ( "formDataKey" ) ;
289
+ return hasFormDataKey ?consumer ( item as GridItemComp ) :true ;
293
290
} ) ;
294
291
}
295
292
validateFormItems ( ) {
@@ -333,12 +330,19 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
333
330
// For the properties, first find in data, then initialData, subcomponent default value (resetValue), empty value (clearValue)
334
331
const newData = { ...( initialData ?? this . children . initialData . getView ( ) ) , ...data } ;
335
332
333
+ // Only proceed if we have data to set
334
+ if ( ! Object . keys ( newData ) . length ) {
335
+ return Promise . resolve ( ) ;
336
+ }
337
+
336
338
return this . runMethodOfItems (
337
339
{
338
340
name :"setValue" ,
339
341
getParams :( t ) => {
340
342
// use component name when formDataKey is empty
341
- const key = t . children . comp . children . formDataKey ?. getView ( ) || t . children . name . getView ( ) ;
343
+ const formDataKey = t . children . comp . children . formDataKey ?. getView ( ) ;
344
+ const componentName = t . children . name . getView ( ) ;
345
+ const key = formDataKey || componentName ;
342
346
const value = newData [ key ] ;
343
347
return value !== undefined ?[ value as EvalParamType ] :undefined ;
344
348
} ,
@@ -347,7 +351,9 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
347
351
name :"setRange" ,
348
352
getParams :( t ) => {
349
353
// use component name when formDataKey is empty
350
- const key = t . children . comp . children . formDataKey ?. getView ( ) || t . children . name . getView ( ) ;
354
+ const formDataKey = t . children . comp . children . formDataKey ?. getView ( ) ;
355
+ const componentName = t . children . name . getView ( ) ;
356
+ const key = formDataKey || componentName ;
351
357
const value = newData [ key ] ?newData [ key ] :undefined ;
352
358
return value !== undefined ?[ value as EvalParamType ] :undefined ;
353
359
} ,
@@ -387,7 +393,8 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
387
393
case CompActionTypes . UPDATE_NODES_V2 :{
388
394
const ret = super . reduce ( action ) ;
389
395
// When the initial value changes, update the form
390
- requestAnimationFrame ( ( ) => {
396
+ if ( action . value [ "initialData" ] !== undefined ) {
397
+ queueMicrotask ( ( ) => {
391
398
this . dispatch (
392
399
customAction < SetDataAction > (
393
400
{
@@ -398,6 +405,7 @@ let FormTmpComp = class extends FormBaseComp implements IForm {
398
405
)
399
406
) ;
400
407
} ) ;
408
+ }
401
409
return ret ;
402
410
}
403
411
case CompActionTypes . CUSTOM :
@@ -548,4 +556,4 @@ export function defaultFormData(compName: string, nameGenerator: NameGenerator):
548
556
showFooter :true ,
549
557
} ,
550
558
} ;
551
- }
559
+ }