Skip to content

Commit

Permalink
Fix: data edge reset bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aarkue committed May 10, 2024
1 parent 809472d commit 48adc47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 2 additions & 7 deletions frontend/src/routes/visual-editor/VisualEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ export default function VisualEditor(props: VisualEditorProps) {
instance.setEdges((es) => {
const newEdges = [...es];
const changedEdge = newEdges.find((e) => e.id === id);
if (changedEdge?.data !== undefined) {
if (changedEdge !== undefined) {
changedEdge.data = { ...changedEdge.data, ...newData };
} else {
console.warn("Did not find changed edge data");
console.warn("Did not find changed edge data for id: " + id);
}
return newEdges;
});
Expand Down Expand Up @@ -357,11 +357,6 @@ export default function VisualEditor(props: VisualEditorProps) {
strokeWidth: 2,
stroke: "#969696",
},
data: {
color: "#969696",
minCount: null,
maxCount: null,
},
}}
proOptions={{ hideAttribution: true }}
onCopyCapture={(ev) => {
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/routes/visual-editor/helper/EventTypeLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { useContext, useState } from "react";
import { useContext, useEffect, useState } from "react";
import { LuHash } from "react-icons/lu";

import { Input } from "@/components/ui/input";
Expand Down Expand Up @@ -41,7 +41,15 @@ export default function EventTypeLink(props: EdgeProps<EventTypeLinkData>) {
});

const { onEdgeDataChange } = useContext(VisualEditorContext);

useEffect(() => {
if (data === undefined) {
onEdgeDataChange(id, {
color: "#969696",
maxCount: null,
minCount: null,
});
}
}, [data]);
return (
<>
<QuantifiedObjectEdge {...props} />
Expand Down

0 comments on commit 48adc47

Please sign in to comment.