mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
🐛 Fix bug with connections deleted when node is renamed (#2467)
* fix bug when node is renamed * update comment * support touch when dragging
This commit is contained in:
parent
889921f5fe
commit
5fd3f8a244
|
@ -74,7 +74,7 @@ export const nodeBase = mixins(
|
||||||
type: inputName,
|
type: inputName,
|
||||||
index,
|
index,
|
||||||
},
|
},
|
||||||
enabled: !this.isReadOnly,
|
enabled: !this.isReadOnly && nodeTypeData.inputs.length > 1, // only enabled for nodes with multiple inputs.. otherwise attachment handled by connectionDrag event in NodeView
|
||||||
dragAllowedWhenFull: true,
|
dragAllowedWhenFull: true,
|
||||||
dropOptions: {
|
dropOptions: {
|
||||||
tolerance: 'touch',
|
tolerance: 'touch',
|
||||||
|
|
|
@ -1522,7 +1522,7 @@ export default mixins(
|
||||||
CanvasHelpers.addOverlays(connection, CanvasHelpers.CONNECTOR_DROP_NODE_OVERLAY);
|
CanvasHelpers.addOverlays(connection, CanvasHelpers.CONNECTOR_DROP_NODE_OVERLAY);
|
||||||
const nodes = [...document.querySelectorAll('.node-default')];
|
const nodes = [...document.querySelectorAll('.node-default')];
|
||||||
|
|
||||||
const onMouseMove = (e: MouseEvent) => {
|
const onMouseMove = (e: MouseEvent | TouchEvent) => {
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1537,7 +1537,8 @@ export default mixins(
|
||||||
const inputMargin = 24;
|
const inputMargin = 24;
|
||||||
const intersecting = nodes.find((element: Element) => {
|
const intersecting = nodes.find((element: Element) => {
|
||||||
const {top, left, right, bottom} = element.getBoundingClientRect();
|
const {top, left, right, bottom} = element.getBoundingClientRect();
|
||||||
if (top <= e.pageY && bottom >= e.pageY && (left - inputMargin) <= e.pageX && right >= e.pageX) {
|
const [x, y] = CanvasHelpers.getMousePosition(e);
|
||||||
|
if (top <= y && bottom >= y && (left - inputMargin) <= x && right >= x) {
|
||||||
const nodeName = (element as HTMLElement).dataset['name'] as string;
|
const nodeName = (element as HTMLElement).dataset['name'] as string;
|
||||||
const node = this.$store.getters.getNodeByName(nodeName) as INodeUi | null;
|
const node = this.$store.getters.getNodeByName(nodeName) as INodeUi | null;
|
||||||
if (node) {
|
if (node) {
|
||||||
|
@ -1562,7 +1563,7 @@ export default mixins(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMouseUp = (e: MouseEvent) => {
|
const onMouseUp = (e: MouseEvent | TouchEvent) => {
|
||||||
this.pullConnActive = false;
|
this.pullConnActive = false;
|
||||||
this.newNodeInsertPosition = this.getMousePositionWithinNodeView(e);
|
this.newNodeInsertPosition = this.getMousePositionWithinNodeView(e);
|
||||||
CanvasHelpers.resetConnectionAfterPull(connection);
|
CanvasHelpers.resetConnectionAfterPull(connection);
|
||||||
|
@ -1571,7 +1572,9 @@ export default mixins(
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('mousemove', onMouseMove);
|
window.addEventListener('mousemove', onMouseMove);
|
||||||
|
window.addEventListener('touchmove', onMouseMove);
|
||||||
window.addEventListener('mouseup', onMouseUp);
|
window.addEventListener('mouseup', onMouseUp);
|
||||||
|
window.addEventListener('touchend', onMouseMove);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e); // eslint-disable-line no-console
|
console.error(e); // eslint-disable-line no-console
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue