From 02a70f4b48adc1d7c890548b6918bba02e93c88a Mon Sep 17 00:00:00 2001 From: xiamidaxia Date: Fri, 25 Apr 2025 15:06:41 +0800 Subject: [PATCH] fix: fixed-layout dragging adder materials check canDrop (#163) --- apps/demo-free-layout/src/styles/index.css | 6 ------ .../src/components/dragging-adder/index.tsx | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/demo-free-layout/src/styles/index.css b/apps/demo-free-layout/src/styles/index.css index b02b7284..d97e8efb 100644 --- a/apps/demo-free-layout/src/styles/index.css +++ b/apps/demo-free-layout/src/styles/index.css @@ -41,12 +41,6 @@ margin-right: 8px; } -.port-if { - position: absolute; - right: 0px; - top: 36px; -} - .mouse-pad-option-icon { display: flex; justify-content: center; diff --git a/packages/materials/fixed-semi-materials/src/components/dragging-adder/index.tsx b/packages/materials/fixed-semi-materials/src/components/dragging-adder/index.tsx index 32b867c5..607f8b52 100644 --- a/packages/materials/fixed-semi-materials/src/components/dragging-adder/index.tsx +++ b/packages/materials/fixed-semi-materials/src/components/dragging-adder/index.tsx @@ -1,7 +1,22 @@ import React from 'react'; +import { FlowDragLayer, usePlayground } from '@flowgram.ai/fixed-layout-editor'; + import { UIDragNodeContainer } from './styles'; -export default function DraggingAdder(): JSX.Element { +export default function DraggingAdder(props: any): JSX.Element { + const playground = usePlayground(); + const layer = playground.getLayer(FlowDragLayer); + if (!layer) return <>; + if ( + layer.options.canDrop && + !layer.options.canDrop({ + dragNodes: layer.dragEntities || [], + dropNode: props.from, + isBranch: false, + }) + ) { + return <>; + } return ; }