From 4e84b14bc74af8109951b0636e1f7aaa4cf5ecfb Mon Sep 17 00:00:00 2001 From: Rain <958414905@qq.com> Date: Mon, 17 Jul 2023 15:27:48 +0800 Subject: [PATCH] fix: avoid crash when field is deleted in Collapse --- packages/core/client/src/block-provider/hooks/index.ts | 2 +- .../core/client/src/collection-manager/hooks/useCollection.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/block-provider/hooks/index.ts b/packages/core/client/src/block-provider/hooks/index.ts index c3b10da723..b646acfc1c 100644 --- a/packages/core/client/src/block-provider/hooks/index.ts +++ b/packages/core/client/src/block-provider/hooks/index.ts @@ -980,7 +980,7 @@ export const useAssociationFilterBlockProps = () => { const fieldSchema = useFieldSchema(); const optionalFieldList = useOptionalFieldList(); const { getDataBlocks } = useFilterBlock(); - const collectionFieldName = collectionField.name; + const collectionFieldName = collectionField?.name; const field = useField(); let list, handleSearchInput, params, run, data, valueKey, labelKey, filterKey; diff --git a/packages/core/client/src/collection-manager/hooks/useCollection.ts b/packages/core/client/src/collection-manager/hooks/useCollection.ts index 1b4d47005a..ced71ea955 100644 --- a/packages/core/client/src/collection-manager/hooks/useCollection.ts +++ b/packages/core/client/src/collection-manager/hooks/useCollection.ts @@ -29,7 +29,7 @@ export const useCollection = () => { return { ...collection, resource, - getField(name: SchemaKey): CollectionFieldOptions | null { + getField(name: SchemaKey): CollectionFieldOptions | undefined { const fields = totalFields as any[]; return fields?.find((field) => field.name === name); },