From 1d01a661936d70467b47738588d10f592de0a06d Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Thu, 30 Nov 2023 17:32:42 +0800 Subject: [PATCH] fix: onTemplateSuccess undefined (#3119) --- .../Configuration/AddFieldAction.tsx | 12 ++++++------ .../client/src/schema-templates/BlockTemplate.tsx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx b/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx index d149e8578..f847095e6 100644 --- a/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx +++ b/packages/core/client/src/collection-manager/Configuration/AddFieldAction.tsx @@ -216,7 +216,7 @@ export const AddFieldAction = (props) => { let children = []; if (include?.length) { include.forEach((k) => { - const field = v.children.find((h) => [k, k.interface].includes(h.value)); + const field = v?.children?.find((h) => [k, k.interface].includes(h.value)); field && children.push({ ...field, @@ -224,13 +224,13 @@ export const AddFieldAction = (props) => { }); }); } else if (exclude?.length) { - children = v.children.filter((v) => { + children = v?.children?.filter((v) => { return !exclude.includes(v.value); }); } else { - children = v.children; + children = v?.children; } - children.length && + children?.length && optionArr.push({ ...v, children, @@ -270,7 +270,7 @@ export const AddFieldAction = (props) => { label: compile(option.label), title: compile(option.label), key: option.label, - children: option.children + children: option?.children .filter((child) => !['o2o', 'subTable', 'linkTo'].includes(child.name)) .map((child) => { return { @@ -284,7 +284,7 @@ export const AddFieldAction = (props) => { }), }; }) - .filter((v) => v.children?.length); + .filter((v) => v?.children?.length); }, [getFieldOptions]); const menu = useMemo(() => { return { diff --git a/packages/core/client/src/schema-templates/BlockTemplate.tsx b/packages/core/client/src/schema-templates/BlockTemplate.tsx index 3c991dac5..590fb9178 100644 --- a/packages/core/client/src/schema-templates/BlockTemplate.tsx +++ b/packages/core/client/src/schema-templates/BlockTemplate.tsx @@ -23,7 +23,7 @@ export const BlockTemplate = observer( const onSuccess = (data) => { fieldSchema['x-linkage-rules'] = data?.data?.['x-linkage-rules'] || []; fieldSchema.setProperties(data?.data?.properties); - onTemplateSuccess(); + onTemplateSuccess?.(); }; return template ? (