fix: fixes issue with connector path not being generated correctly

This commit is contained in:
Mark Mankarious 2023-10-17 14:17:55 +01:00
parent 0731757060
commit 425744585e
2 changed files with 38 additions and 9 deletions

View file

@ -45,6 +45,12 @@ export const Connector: ModeActions = {
id: itemAtTile.id
}
};
draft.connector.path = getConnectorPath({
anchors: draft.connector.anchors,
nodes: scene.nodes,
allAnchors: getAllAnchors(scene.connectors)
});
});
uiState.actions.setMode(newMode);

View file

@ -4,7 +4,8 @@ import {
getItemById,
CoordsUtils,
hasMovedTile,
getAnchorParent
getAnchorParent,
getItemAtTile
} from 'src/utils';
const dragItems = (
@ -41,8 +42,28 @@ const dragItems = (
item.id
);
if (anchor.ref.type !== 'TILE') return;
const itemAtTile = getItemAtTile({ tile, scene });
switch (itemAtTile?.type) {
case 'NODE':
draft.anchors[anchorIndex] = {
...anchor,
ref: {
type: 'NODE',
id: itemAtTile.id
}
};
break;
case 'CONNECTOR_ANCHOR':
draft.anchors[anchorIndex] = {
...anchor,
ref: {
type: 'ANCHOR',
id: itemAtTile.id
}
};
break;
default:
draft.anchors[anchorIndex] = {
...anchor,
ref: {
@ -50,6 +71,8 @@ const dragItems = (
coords: tile
}
};
break;
}
});
scene.actions.updateConnector(connector.id, newConnector);