diff --git a/packages/core/client/src/schema-component/antd/association-field/AssociationFieldProvider.tsx b/packages/core/client/src/schema-component/antd/association-field/AssociationFieldProvider.tsx index be31cc28e..bcc2dc2cc 100644 --- a/packages/core/client/src/schema-component/antd/association-field/AssociationFieldProvider.tsx +++ b/packages/core/client/src/schema-component/antd/association-field/AssociationFieldProvider.tsx @@ -28,18 +28,20 @@ export const AssociationFieldProvider = observer( [fieldSchema['x-component-props']?.mode], ); - const targetKeyValue = useMemo(() => { - if (!field.value) return ''; - if (['belongsTo', 'hasOne'].includes(collectionField.type)) { - return field.value[collectionField.targetKey] ?? ''; - } - if (['belongsToMany', 'hasMany'].includes(collectionField.type)) { - if (Array.isArray(field.value)) { - return field.value.map((v) => v[collectionField.targetKey] ?? '').join(','); - } - } - return ''; - }, [collectionField, field.value]); + // const targetKeyValue = useMemo(() => { + // if (!field.value) return ''; + // if (['belongsTo', 'hasOne'].includes(collectionField.type)) { + // return field.value[collectionField.targetKey] ?? ''; + // } + // if (['belongsToMany', 'hasMany'].includes(collectionField.type)) { + // if (Array.isArray(field.value)) { + // return field.value.map((v) => v[collectionField.targetKey] ?? '').join(','); + // } + // } + // return ''; + // }, [collectionField, field.value]); + + const fieldValue = useMemo(() => JSON.stringify(field.value), [field.value]); const [loading, setLoading] = useState(true); @@ -84,7 +86,7 @@ export const AssociationFieldProvider = observer( } setLoading(false); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [currentMode, collectionField, targetKeyValue]); + }, [currentMode, collectionField, fieldValue]); if (loading) { return null;