Skip to content

Commit fb172cf

Browse files
committed
all issues fixed
1 parent 423437a commit fb172cf

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

app/page.jsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ export default function Page() {
8484
const targetNode = nodes.find((node) => node.id === params.target);
8585

8686
if (
87-
sourceNode?.type === "LabeledGroupNode" &&
88-
targetNode?.type === "LabeledGroupNode"
87+
sourceNode?.type === "CustomChildNode" &&
88+
(targetNode?.type === "LabeledGroupNode" ||
89+
targetNode.extent !== "parent")
8990
) {
91+
toast.error("Invalid Connection");
92+
return;
93+
}
94+
95+
if (sourceNode?.type === "LabeledGroupNode") {
9096
const newEdge = {
9197
...params,
9298
type: "CustomEdge",

components/custom-edge.jsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,14 @@ const CustomEdge = ({
6060
};
6161

6262
return (
63-
<>
63+
<g onDoubleClick={openModal}>
6464
<BaseEdge
6565
id={id}
6666
path={edgePath}
6767
{...props}
6868
interactionWidth={20}
69-
onDoubleClick={openModal}
7069
/>
71-
<EdgeLabelRenderer>
70+
<EdgeLabelRenderer onDoubleClick={openModal}>
7271
<div
7372
style={{
7473
position: "absolute",
@@ -77,8 +76,9 @@ const CustomEdge = ({
7776
paddingBlock: 4,
7877
borderRadius: 2,
7978
fontSize: 10,
79+
pointerEvents: "all",
8080
}}
81-
className="nodrag nopan items-left flex flex-col gap-1 border border-yellow-700 bg-[#ffcc00] font-semibold text-black"
81+
className="nodrag nopan items-left flex cursor-pointer flex-col gap-1 border border-yellow-700 bg-[#ffcc00] font-semibold text-black"
8282
>
8383
<div className="flex items-center gap-1">
8484
<SquarePlus size={10} />
@@ -87,7 +87,10 @@ const CustomEdge = ({
8787
{data.result && ( // Only show result if it's not empty
8888
<div className="flex items-center gap-1">
8989
<Flag size={10} />
90-
Result: {data.result}
90+
Result:{" "}
91+
<span className="max-w-44 truncate text-yellow-900">
92+
{data.result}
93+
</span>
9194
</div>
9295
)}
9396
</div>
@@ -127,7 +130,7 @@ const CustomEdge = ({
127130
</DialogContent>
128131
</Dialog>
129132
)}
130-
</>
133+
</g>
131134
);
132135
};
133136

0 commit comments

Comments
 (0)