diff --git a/packages/core/client/src/block-provider/BlockProvider.tsx b/packages/core/client/src/block-provider/BlockProvider.tsx index 2ee77cb3e..accdc3e0c 100644 --- a/packages/core/client/src/block-provider/BlockProvider.tsx +++ b/packages/core/client/src/block-provider/BlockProvider.tsx @@ -34,6 +34,7 @@ interface UseResourceProps { resource: any; association?: any; useSourceId?: any; + collection?: any; block?: any; } @@ -48,7 +49,7 @@ export const useAssociation = (props) => { }; const useResource = (props: UseResourceProps) => { - const { block, resource, useSourceId } = props; + const { block, collection, resource, useSourceId } = props; const record = useRecord(); const api = useAPIClient(); const { fieldSchema } = useActionContext(); @@ -83,8 +84,10 @@ const useResource = (props: UseResourceProps) => { if (sourceId) { return api.resource(resource, sourceId); } - - return api.resource(resource, record[association?.sourceKey || 'id']); + if (record[association?.sourceKey || 'id']) { + return api.resource(resource, record[association?.sourceKey || 'id']); + } + return api.resource(collection); }; const useActionParams = (props) => { @@ -271,6 +274,7 @@ export const RenderChildrenWithAssociationFilter: React.FC = (props) => { }; export const BlockProvider = (props) => { + console.log(props); const { collection, association } = props; const resource = useResource(props); const params = { ...props.params };