From 01134f8253800cf8c37d32d7c46de246625b3b1b Mon Sep 17 00:00:00 2001 From: chenos Date: Fri, 22 Apr 2022 11:13:06 +0800 Subject: [PATCH] fix: allow collection provider to be null --- .../client/src/collection-manager/CollectionProvider.tsx | 6 +++--- .../antd/record-picker/InputRecordPicker.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/collection-manager/CollectionProvider.tsx b/packages/core/client/src/collection-manager/CollectionProvider.tsx index 8b9e8271ee..2150ce225c 100644 --- a/packages/core/client/src/collection-manager/CollectionProvider.tsx +++ b/packages/core/client/src/collection-manager/CollectionProvider.tsx @@ -3,11 +3,11 @@ import { CollectionContext } from './context'; import { useCollectionManager } from './hooks'; import { CollectionOptions } from './types'; -export const CollectionProvider: React.FC<{ name?: string; collection?: CollectionOptions }> = (props) => { - const { name, collection, children } = props; +export const CollectionProvider: React.FC<{ allowNull?: boolean; name?: string; collection?: CollectionOptions }> = (props) => { + const { allowNull, name, collection, children } = props; const { getCollection } = useCollectionManager(); const value = getCollection(collection || name); - if (!value) { + if (!value && !allowNull) { return null; } return {children}; diff --git a/packages/core/client/src/schema-component/antd/record-picker/InputRecordPicker.tsx b/packages/core/client/src/schema-component/antd/record-picker/InputRecordPicker.tsx index 4f01cf2416..53d6b40723 100644 --- a/packages/core/client/src/schema-component/antd/record-picker/InputRecordPicker.tsx +++ b/packages/core/client/src/schema-component/antd/record-picker/InputRecordPicker.tsx @@ -97,7 +97,7 @@ export const InputRecordPicker: React.FC = (props) => { open={false} /> - +