fix(xyhandle): only fire end events when connection started #5315
This commit is contained in:
@@ -112,6 +112,7 @@ function onPointerDown(
|
|||||||
};
|
};
|
||||||
|
|
||||||
function startConnection() {
|
function startConnection() {
|
||||||
|
connectionStarted = true;
|
||||||
updateConnection(previousConnection);
|
updateConnection(previousConnection);
|
||||||
onConnectStart?.(event, { nodeId, handleId, handleType });
|
onConnectStart?.(event, { nodeId, handleId, handleType });
|
||||||
}
|
}
|
||||||
@@ -132,8 +133,6 @@ function onPointerDown(
|
|||||||
}
|
}
|
||||||
|
|
||||||
startConnection();
|
startConnection();
|
||||||
|
|
||||||
connectionStarted = nextConnectionStarted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getFromHandle() || !fromHandle) {
|
if (!getFromHandle() || !fromHandle) {
|
||||||
@@ -208,24 +207,27 @@ function onPointerDown(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onPointerUp(event: MouseEvent | TouchEvent) {
|
function onPointerUp(event: MouseEvent | TouchEvent) {
|
||||||
if ((closestHandle || handleDomNode) && connection && isValid) {
|
if (connectionStarted) {
|
||||||
onConnect?.(connection);
|
if ((closestHandle || handleDomNode) && connection && isValid) {
|
||||||
}
|
onConnect?.(connection);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* it's important to get a fresh reference from the store here
|
* it's important to get a fresh reference from the store here
|
||||||
* in order to get the latest state of onConnectEnd
|
* in order to get the latest state of onConnectEnd
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const { inProgress, ...connectionState } = previousConnection;
|
const { inProgress, ...connectionState } = previousConnection;
|
||||||
const finalConnectionState = {
|
const finalConnectionState = {
|
||||||
...connectionState,
|
...connectionState,
|
||||||
toPosition: previousConnection.toHandle ? previousConnection.toPosition : null,
|
toPosition: previousConnection.toHandle ? previousConnection.toPosition : null,
|
||||||
};
|
};
|
||||||
onConnectEnd?.(event, finalConnectionState);
|
|
||||||
|
|
||||||
if (edgeUpdaterType) {
|
onConnectEnd?.(event, finalConnectionState);
|
||||||
onReconnectEnd?.(event, finalConnectionState);
|
|
||||||
|
if (edgeUpdaterType) {
|
||||||
|
onReconnectEnd?.(event, finalConnectionState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelConnection();
|
cancelConnection();
|
||||||
|
|||||||
Reference in New Issue
Block a user