fix: tableField query data in add child action (#1876)

This commit is contained in:
katherinehhh 2023-05-25 12:23:48 +08:00 committed by GitHub
parent 49117afb72
commit 0086037425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,8 @@ const useResource = (props: UseResourceProps) => {
const { block, resource, useSourceId } = props;
const record = useRecord();
const api = useAPIClient();
const { fieldSchema } = useActionContext();
const isCreateAction = fieldSchema?.['x-action'] === 'create';
const association = useAssociation(props);
const sourceId = useSourceId?.();
const field = useField<Field>();
@ -59,7 +61,9 @@ const useResource = (props: UseResourceProps) => {
field,
api,
resource,
sourceId: sourceId || record[association?.sourceKey || 'id'] || record?.__parent?.[association?.sourceKey || 'id'],
sourceId: !isCreateAction
? sourceId || record[association?.sourceKey || 'id'] || record?.__parent?.[association?.sourceKey || 'id']
: undefined,
};
return new TableFieldResource(options);
}