fix: subform disappears (#3073)

This commit is contained in:
被雨水过滤的空气-Rain 2023-11-22 17:22:09 +08:00 committed by GitHub
parent cc40849c59
commit ea136ab6bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ const useLazyLoadDisplayAssociationFieldsOfForm = () => {
const { isInSubForm, isInSubTable } = useFlag() || {}; const { isInSubForm, isInSubTable } = useFlag() || {};
const schemaName = fieldSchema.name.toString(); const schemaName = fieldSchema.name.toString();
const formValue = isInSubForm || isInSubTable ? subFormValue : form.values; const formValue = _.cloneDeep(isInSubForm || isInSubTable ? subFormValue : form.values);
const collectionFieldRef = useRef(null); const collectionFieldRef = useRef(null);
if (collectionFieldRef.current == null) { if (collectionFieldRef.current == null) {
@ -66,7 +66,13 @@ const useLazyLoadDisplayAssociationFieldsOfForm = () => {
.parseVariable(variableString, formVariable) .parseVariable(variableString, formVariable)
.then((value) => { .then((value) => {
nextTick(() => { nextTick(() => {
field.value = transformVariableValue(value, { targetCollectionField: collectionFieldRef.current }); const result = transformVariableValue(value, { targetCollectionField: collectionFieldRef.current });
// fix https://nocobase.height.app/T-2608
if (_.isEmpty(result)) {
field.value = null;
} else {
field.value = result;
}
}); });
}) })
.catch((err) => { .catch((err) => {