🐛 (editor) Improve edge resiliency connected to non-existant blocks
This commit is contained in:
@ -60,13 +60,18 @@ export const Edge = ({ edge, fromGroupId }: Props) => {
|
|||||||
return sourceEndpointYOffsets.get(endpointId)?.y
|
return sourceEndpointYOffsets.get(endpointId)?.y
|
||||||
}, [edge.from, sourceEndpointYOffsets])
|
}, [edge.from, sourceEndpointYOffsets])
|
||||||
|
|
||||||
const targetTop = useMemo(
|
const targetTop = useMemo(() => {
|
||||||
() =>
|
if (edge.to.blockId) {
|
||||||
edge?.to.blockId
|
const targetOffset = targetEndpointYOffsets.get(edge.to.blockId)
|
||||||
? targetEndpointYOffsets.get(edge?.to.blockId)?.y
|
if (!targetOffset) {
|
||||||
: undefined,
|
// Something went wrong, the edge is connected to a block that doesn't exist anymore.
|
||||||
[edge?.to.blockId, targetEndpointYOffsets]
|
deleteEdge(edge.id)
|
||||||
)
|
return
|
||||||
|
}
|
||||||
|
return targetOffset.y
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}, [deleteEdge, edge.id, edge.to.blockId, targetEndpointYOffsets])
|
||||||
|
|
||||||
const path = useMemo(() => {
|
const path = useMemo(() => {
|
||||||
if (!sourceElementCoordinates || !toGroupCoordinates || !sourceTop)
|
if (!sourceElementCoordinates || !toGroupCoordinates || !sourceTop)
|
||||||
|
Reference in New Issue
Block a user