fix: fix Menu dismiss on Drag&Drop (#1772)
This commit is contained in:
parent
89938191a3
commit
7feeda4906
@ -363,7 +363,7 @@ Menu.Item = observer((props) => {
|
|||||||
eventKey={schema.name}
|
eventKey={schema.name}
|
||||||
schema={schema}
|
schema={schema}
|
||||||
>
|
>
|
||||||
<SortableItem className={designerCss}>
|
<SortableItem className={designerCss} removeParentsIfNoChildren={false}>
|
||||||
<Icon type={icon} />
|
<Icon type={icon} />
|
||||||
<span
|
<span
|
||||||
className={css`
|
className={css`
|
||||||
@ -402,7 +402,7 @@ Menu.URL = observer((props) => {
|
|||||||
window.open(props.href, '_blank');
|
window.open(props.href, '_blank');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<SortableItem className={designerCss}>
|
<SortableItem className={designerCss} removeParentsIfNoChildren={false}>
|
||||||
<Icon type={icon} />
|
<Icon type={icon} />
|
||||||
<span
|
<span
|
||||||
className={css`
|
className={css`
|
||||||
@ -441,7 +441,7 @@ Menu.SubMenu = observer((props) => {
|
|||||||
key={schema.name}
|
key={schema.name}
|
||||||
eventKey={schema.name}
|
eventKey={schema.name}
|
||||||
title={
|
title={
|
||||||
<SortableItem className={subMenuDesignerCss}>
|
<SortableItem className={subMenuDesignerCss} removeParentsIfNoChildren={false}>
|
||||||
<Icon type={icon} />
|
<Icon type={icon} />
|
||||||
{field.title}
|
{field.title}
|
||||||
<Designer />
|
<Designer />
|
||||||
|
@ -19,6 +19,7 @@ const useDragEnd = (props?: any) => {
|
|||||||
const breakRemoveOn = over?.data?.current?.breakRemoveOn;
|
const breakRemoveOn = over?.data?.current?.breakRemoveOn;
|
||||||
const wrapSchema = over?.data?.current?.wrapSchema;
|
const wrapSchema = over?.data?.current?.wrapSchema;
|
||||||
const onSuccess = over?.data?.current?.onSuccess;
|
const onSuccess = over?.data?.current?.onSuccess;
|
||||||
|
const removeParentsIfNoChildren = over.data.current.removeParentsIfNoChildren ?? true;
|
||||||
|
|
||||||
if (!activeSchema || !overSchema) {
|
if (!activeSchema || !overSchema) {
|
||||||
props?.onDragEnd?.(event);
|
props?.onDragEnd?.(event);
|
||||||
@ -49,7 +50,7 @@ const useDragEnd = (props?: any) => {
|
|||||||
dn.insertAdjacent(insertAdjacent, activeSchema, {
|
dn.insertAdjacent(insertAdjacent, activeSchema, {
|
||||||
wrap: wrapSchema,
|
wrap: wrapSchema,
|
||||||
breakRemoveOn,
|
breakRemoveOn,
|
||||||
removeParentsIfNoChildren: true,
|
removeParentsIfNoChildren,
|
||||||
onSuccess,
|
onSuccess,
|
||||||
});
|
});
|
||||||
props?.onDragEnd?.(event);
|
props?.onDragEnd?.(event);
|
||||||
|
@ -57,8 +57,9 @@ const useSortableItemId = (props) => {
|
|||||||
|
|
||||||
export const SortableItem: React.FC<any> = observer((props) => {
|
export const SortableItem: React.FC<any> = observer((props) => {
|
||||||
const { schema, id, ...others } = useSortableItemProps(props);
|
const { schema, id, ...others } = useSortableItemProps(props);
|
||||||
|
const removeParentsIfNoChildren = others.removeParentsIfNoChildren ?? true;
|
||||||
return (
|
return (
|
||||||
<SortableProvider id={id} data={{ insertAdjacent: 'afterEnd', schema: schema }}>
|
<SortableProvider id={id} data={{ insertAdjacent: 'afterEnd', schema: schema, removeParentsIfNoChildren }}>
|
||||||
<Sortable {...others}>{props.children}</Sortable>
|
<Sortable {...others}>{props.children}</Sortable>
|
||||||
</SortableProvider>
|
</SortableProvider>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user