fix: table column field failed to be actived (#2309)

This commit is contained in:
katherinehhh 2023-07-24 23:59:17 +08:00 committed by GitHub
parent 68976e0ebe
commit d068f9b5df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,17 +1,20 @@
import { observer, RecursionField } from '@formily/react';
import React from 'react';
import { useCollectionManager } from '../../../../collection-manager';
import { useRecord } from '../../../../record-provider';
export const ColumnFieldProvider = observer(
(props: { schema: any; basePath: any; children: any }) => {
const { schema, basePath } = props;
const record = useRecord();
const { getCollectionJoinField } = useCollectionManager();
const fieldSchema = schema.reduceProperties((buf, s) => {
if (s['x-component'] === 'CollectionField') {
return s;
}
return buf;
}, null);
if (fieldSchema && record?.__collection) {
const collectionField = fieldSchema && getCollectionJoinField(fieldSchema['x-collection-field']);
if (fieldSchema && record?.__collection && ['select', 'multipleSelect'].includes(collectionField.interface)) {
const fieldName = `${record.__collection}.${fieldSchema.name}`;
schema.properties[fieldSchema.name]['x-collection-field'] = fieldName;
return <RecursionField basePath={basePath} schema={schema} onlyRenderProperties />;