diff --git a/src/frontend/src/icons/GradientSparkles/index.tsx b/src/frontend/src/icons/GradientSparkles/index.tsx index 470708f89..31d939f3d 100644 --- a/src/frontend/src/icons/GradientSparkles/index.tsx +++ b/src/frontend/src/icons/GradientSparkles/index.tsx @@ -56,7 +56,11 @@ export const GradientGroup = (props) => { - + ); }; diff --git a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx index 1c6951726..bc0a0e362 100644 --- a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx @@ -483,6 +483,7 @@ export default function Page({ > )} { diff --git a/src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx index 2c3804ca8..949e22fb6 100644 --- a/src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx @@ -1,11 +1,31 @@ import { useEffect, useState } from "react"; import { NodeToolbar } from "reactflow"; import { GradientGroup } from "../../../../icons/GradientSparkles"; -export default function SelectionMenu({ onClick, nodes, isVisible }) { +import { validateSelection } from "../../../../utils/reactflowUtils"; +import useFlowStore from "../../../../stores/flowStore"; +export default function SelectionMenu({ + onClick, + nodes, + isVisible, + lastSelection, +}) { + const edges = useFlowStore((state) => state.edges); + const [disable, setDisable] = useState( + lastSelection && edges.length > 0 + ? validateSelection(lastSelection!, edges).length > 0 + : false, + ); const [isOpen, setIsOpen] = useState(false); const [isTransitioning, setIsTransitioning] = useState(false); const [lastNodes, setLastNodes] = useState(nodes); + useEffect(() => { + if (isOpen) { + return setDisable(validateSelection(lastSelection!, edges).length > 0); + } + setDisable(false); + }, [isOpen, setIsOpen]); + // nodes get saved to not be gone after the toolbar closes useEffect(() => { setLastNodes(nodes); @@ -42,13 +62,15 @@ export default function SelectionMenu({ onClick, nodes, isVisible }) { } >