From 108453f90c3f2d4b6c153b126500a35e0d07bf62 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Thu, 26 Oct 2023 16:41:38 +0800 Subject: [PATCH] fix: association block was not associated after adding data (#2907) --- packages/core/client/src/block-provider/BlockProvider.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/client/src/block-provider/BlockProvider.tsx b/packages/core/client/src/block-provider/BlockProvider.tsx index e065ae818..99784e1fa 100644 --- a/packages/core/client/src/block-provider/BlockProvider.tsx +++ b/packages/core/client/src/block-provider/BlockProvider.tsx @@ -64,6 +64,7 @@ const useResource = (props: UseResourceProps) => { const { fieldSchema } = useActionContext(); const isCreateAction = fieldSchema?.['x-action'] === 'create'; const association = useAssociation(props); + console.log(association); const sourceId = useSourceId?.(); const field = useField(); const withoutTableFieldResource = useContext(WithoutTableFieldResource); @@ -96,6 +97,9 @@ const useResource = (props: UseResourceProps) => { if (record[association?.sourceKey || 'id']) { return api.resource(resource, record[association?.sourceKey || 'id']); } + if (record?.__parent?.[association?.sourceKey || 'id']) { + return api.resource(resource, record.__parent[association?.sourceKey || 'id']); + } return api.resource(collection); };