fix: fix Menu dismiss on Drag&Drop (#1772)

This commit is contained in:
李小斐 2023-05-05 11:03:49 +08:00 committed by GitHub
parent 89938191a3
commit 7feeda4906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -363,7 +363,7 @@ Menu.Item = observer((props) => {
eventKey={schema.name}
schema={schema}
>
<SortableItem className={designerCss}>
<SortableItem className={designerCss} removeParentsIfNoChildren={false}>
<Icon type={icon} />
<span
className={css`
@ -402,7 +402,7 @@ Menu.URL = observer((props) => {
window.open(props.href, '_blank');
}}
>
<SortableItem className={designerCss}>
<SortableItem className={designerCss} removeParentsIfNoChildren={false}>
<Icon type={icon} />
<span
className={css`
@ -441,7 +441,7 @@ Menu.SubMenu = observer((props) => {
key={schema.name}
eventKey={schema.name}
title={
<SortableItem className={subMenuDesignerCss}>
<SortableItem className={subMenuDesignerCss} removeParentsIfNoChildren={false}>
<Icon type={icon} />
{field.title}
<Designer />

View File

@ -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);

View File

@ -57,8 +57,9 @@ const useSortableItemId = (props) => {
export const SortableItem: React.FC<any> = observer((props) => {
const { schema, id, ...others } = useSortableItemProps(props);
const removeParentsIfNoChildren = others.removeParentsIfNoChildren ?? true;
return (
<SortableProvider id={id} data={{ insertAdjacent: 'afterEnd', schema: schema }}>
<SortableProvider id={id} data={{ insertAdjacent: 'afterEnd', schema: schema, removeParentsIfNoChildren }}>
<Sortable {...others}>{props.children}</Sortable>
</SortableProvider>
);