@@ -288,9 +288,12 @@ const FieldSettingBase = (props: IFieldSettingBase) => {
288288
289289 const onFieldEditorChange = useCallback (
290290 ( nextField : IFieldEditorRo ) => {
291+ const sanitizedLookupOptions = sanitizeLookupOptions ( nextField . lookupOptions ) ;
291292 const normalizedField : IFieldEditorRo = {
292293 ...nextField ,
293- lookupOptions : sanitizeLookupOptions ( nextField . lookupOptions ) ,
294+ lookupOptions :
295+ sanitizedLookupOptions ??
296+ ( nextField . isConditionalLookup ? nextField . lookupOptions : undefined ) ,
294297 } ;
295298 setField ( normalizedField ) ;
296299 setUpdateCount ( 1 ) ;
@@ -313,13 +316,18 @@ const FieldSettingBase = (props: IFieldSettingBase) => {
313316 return ;
314317 }
315318
319+ const normalizedField : IFieldEditorRo = {
320+ ...field ,
321+ lookupOptions : sanitizeLookupOptions ( field . lookupOptions ) ,
322+ } ;
323+
316324 const validateRes = validateFieldOptions ( {
317- type : field . type as FieldType ,
318- isLookup : field . isLookup ,
319- isConditionalLookup : field . isConditionalLookup ,
320- lookupOptions : field . lookupOptions ,
321- options : field . options ,
322- aiConfig : field . aiConfig ,
325+ type : normalizedField . type as FieldType ,
326+ isLookup : normalizedField . isLookup ,
327+ isConditionalLookup : normalizedField . isConditionalLookup ,
328+ lookupOptions : normalizedField . lookupOptions ,
329+ options : normalizedField . options ,
330+ aiConfig : normalizedField . aiConfig ,
323331 } ) ;
324332 if ( validateRes . length > 0 ) {
325333 toast . error (
@@ -333,7 +341,7 @@ const FieldSettingBase = (props: IFieldSettingBase) => {
333341
334342 const fieldRoSchema =
335343 operator === FieldOperator . Edit ? convertFieldRoSchema : createFieldRoSchema ;
336- const result = fieldRoSchema . safeParse ( field ) ;
344+ const result = fieldRoSchema . safeParse ( normalizedField ) ;
337345 if ( result . success ) {
338346 setIsSaving ( true ) ;
339347 try {
@@ -344,7 +352,7 @@ const FieldSettingBase = (props: IFieldSettingBase) => {
344352 return ;
345353 }
346354
347- console . error ( 'fieldConFirm' , field ) ;
355+ console . error ( 'fieldConFirm' , normalizedField ) ;
348356 console . error ( 'fieldConFirmResult' , fromZodError ( result . error ) . message ) ;
349357 const errorMessage = fromZodError ( result . error ) . message ;
350358 toast . error ( `Validation Error` , {
0 commit comments