From 7feeda490614f7906e4084e00718237b1919cdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=8F=E6=96=90?= Date: Fri, 5 May 2023 11:03:49 +0800 Subject: [PATCH] fix: fix Menu dismiss on Drag&Drop (#1772) --- .../core/client/src/schema-component/antd/menu/Menu.tsx | 6 +++--- .../src/schema-component/common/dnd-context/index.tsx | 3 ++- .../schema-component/common/sortable-item/SortableItem.tsx | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/menu/Menu.tsx b/packages/core/client/src/schema-component/antd/menu/Menu.tsx index d24eb89ef..f0c46d3c5 100644 --- a/packages/core/client/src/schema-component/antd/menu/Menu.tsx +++ b/packages/core/client/src/schema-component/antd/menu/Menu.tsx @@ -363,7 +363,7 @@ Menu.Item = observer((props) => { eventKey={schema.name} schema={schema} > - + { window.open(props.href, '_blank'); }} > - + { key={schema.name} eventKey={schema.name} title={ - + {field.title} diff --git a/packages/core/client/src/schema-component/common/dnd-context/index.tsx b/packages/core/client/src/schema-component/common/dnd-context/index.tsx index 33aee7bfb..c17f15a70 100644 --- a/packages/core/client/src/schema-component/common/dnd-context/index.tsx +++ b/packages/core/client/src/schema-component/common/dnd-context/index.tsx @@ -19,6 +19,7 @@ const useDragEnd = (props?: any) => { const breakRemoveOn = over?.data?.current?.breakRemoveOn; const wrapSchema = over?.data?.current?.wrapSchema; const onSuccess = over?.data?.current?.onSuccess; + const removeParentsIfNoChildren = over.data.current.removeParentsIfNoChildren ?? true; if (!activeSchema || !overSchema) { props?.onDragEnd?.(event); @@ -49,7 +50,7 @@ const useDragEnd = (props?: any) => { dn.insertAdjacent(insertAdjacent, activeSchema, { wrap: wrapSchema, breakRemoveOn, - removeParentsIfNoChildren: true, + removeParentsIfNoChildren, onSuccess, }); props?.onDragEnd?.(event); diff --git a/packages/core/client/src/schema-component/common/sortable-item/SortableItem.tsx b/packages/core/client/src/schema-component/common/sortable-item/SortableItem.tsx index 1e8b3dec5..552583f22 100644 --- a/packages/core/client/src/schema-component/common/sortable-item/SortableItem.tsx +++ b/packages/core/client/src/schema-component/common/sortable-item/SortableItem.tsx @@ -57,8 +57,9 @@ const useSortableItemId = (props) => { export const SortableItem: React.FC = observer((props) => { const { schema, id, ...others } = useSortableItemProps(props); + const removeParentsIfNoChildren = others.removeParentsIfNoChildren ?? true; return ( - + {props.children} );