Skip to content

Commit d3bc77d

Browse files
committed
Add default relationship color to handle old versions
Issue : #651
1 parent 2e64de1 commit d3bc77d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/components/EditorCanvas/Relationship.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { useMemo, useRef, useState, useEffect } from "react";
2-
import { Cardinality, ObjectType, Tab } from "../../data/constants";
2+
import {
3+
Cardinality,
4+
defaultBlue,
5+
ObjectType,
6+
Tab,
7+
} from "../../data/constants";
38
import { calcPath } from "../../utils/calcPath";
49
import { useDiagram, useSettings, useLayout, useSelect } from "../../hooks";
510
import { useTranslation } from "react-i18next";
@@ -127,7 +132,7 @@ export default function Relationship({ data }) {
127132
className="relationship-path"
128133
fill="none"
129134
cursor="pointer"
130-
style={{ stroke: data.color }}
135+
style={{ stroke: data.color ?? defaultBlue }}
131136
/>
132137
{settings.showRelationshipLabels && (
133138
<text

src/components/EditorSidePanel/RelationshipsTab/RelationshipInfo.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Constraint,
1818
Action,
1919
ObjectType,
20+
defaultBlue,
2021
} from "../../../data/constants";
2122
import { useDiagram, useLayout, useUndoRedo } from "../../../hooks";
2223
import i18n from "../../../i18n/i18n";
@@ -41,7 +42,7 @@ export default function RelationshipInfo({ data }) {
4142
const { t } = useTranslation();
4243
const { layout } = useLayout();
4344
const [editField, setEditField] = useState({});
44-
const initialColorRef = useRef(data.color);
45+
const initialColorRef = useRef(data.color ?? defaultBlue);
4546

4647

4748
const relValues = useMemo(() => {
@@ -215,7 +216,7 @@ export default function RelationshipInfo({ data }) {
215216
<ColorPicker
216217
usePopover={true}
217218
readOnly={layout.readOnly}
218-
value={data.color}
219+
value={data.color ?? defaultBlue}
219220
onChange={(color) => updateRelationship(data.id, { color })}
220221
onColorPick={(color) => handleColorPick(color)}
221222
/>

0 commit comments

Comments
 (0)