Canvas: Connection original persistence check (#86476)

* Canvas: Connection original persistence check

* modify current connection state directly instead of copying and needing to call "onChange"

---------

Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
This commit is contained in:
Drew Slobodnjak 2024-04-29 08:23:26 -07:00 committed by GitHub
parent 4e6ba433de
commit 7590f4afe1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,7 +128,7 @@ export const ConnectionSVG = ({
// Render selected connection last, ensuring it is above other connections
.sort((_a, b) => (selectedConnection === b && scene.panel.context.instanceState.selectedConnection ? -1 : 0))
.map((v, idx) => {
const { source, target, info, vertices } = v;
const { source, target, info, vertices, index } = v;
const sourceRect = source.div?.getBoundingClientRect();
const parent = source.div?.parentElement;
const transformScale = scene.scale;
@ -146,6 +146,15 @@ export const ConnectionSVG = ({
yStart = v.sourceOriginal.y;
xEnd = v.targetOriginal.x;
yEnd = v.targetOriginal.y;
} else if (source.options.connections) {
// If original source or target coordinates are not set for the current connection, set them
if (
!source.options.connections[index].sourceOriginal ||
!source.options.connections[index].targetOriginal
) {
source.options.connections[index].sourceOriginal = { x: x1, y: y1 };
source.options.connections[index].targetOriginal = { x: x2, y: y2 };
}
}
const midpoint = calculateMidpoint(x1, y1, x2, y2);