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}
 | 
			
		||||
      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 />
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
@ -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>
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user