From 186da56bdc8cc070112b1d81682303bdb3eeae85 Mon Sep 17 00:00:00 2001 From: chenos Date: Sat, 11 Mar 2023 09:42:00 +0800 Subject: [PATCH] fix(collection-manager): filter out empty --- .../src/collection-manager/hooks/useCollectionManager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/collection-manager/hooks/useCollectionManager.ts b/packages/core/client/src/collection-manager/hooks/useCollectionManager.ts index cba6881f68..2f20113419 100644 --- a/packages/core/client/src/collection-manager/hooks/useCollectionManager.ts +++ b/packages/core/client/src/collection-manager/hooks/useCollectionManager.ts @@ -19,11 +19,11 @@ export const useCollectionManager = () => { }, [], ); - return inheritedFields; + return inheritedFields.filter(Boolean); }; const getCollectionFields = (name: string): CollectionFieldOptions[] => { - const currentFields = collections?.find((collection) => collection.name === name)?.fields; + const currentFields = collections?.find((collection) => collection.name === name)?.fields || []; const inheritedFields = getInheritedFields(name); const totalFields = unionBy(currentFields?.concat(inheritedFields) || [], 'name').filter((v: any) => { return !v.isForeignKey; @@ -174,8 +174,8 @@ export const useCollectionManager = () => { return templates[name] ? clone(templates[name] || templates['general']) : null; }, getParentCollectionFields: (parentCollection, currentCollection) => { - const currentFields = collections?.find((collection) => collection.name === currentCollection)?.fields; - const parentFields = collections?.find((collection) => collection.name === parentCollection)?.fields; + const currentFields = collections?.find((collection) => collection.name === currentCollection)?.fields || []; + const parentFields = collections?.find((collection) => collection.name === parentCollection)?.fields || []; const inheritKeys = getInheritCollections(currentCollection); const index = inheritKeys.indexOf(parentCollection); let filterFields = currentFields;