diff --git a/packages/editor-ui/src/components/NodeCreator/MainPanel.vue b/packages/editor-ui/src/components/NodeCreator/MainPanel.vue index d0ad6c7b8777b..b3371187a61c0 100644 --- a/packages/editor-ui/src/components/NodeCreator/MainPanel.vue +++ b/packages/editor-ui/src/components/NodeCreator/MainPanel.vue @@ -1,5 +1,9 @@ @@ -78,6 +85,12 @@ export default Vue.extend({ isTrigger (): boolean { return this.nodeType.group.includes('trigger'); }, + draggableStyle(): { top: string; left: string; } { + return { + top: `${this.draggablePosition.y}px`, + left: `${this.draggablePosition.x}px`, + }; + }, }, mounted() { /** @@ -100,8 +113,8 @@ export default Vue.extend({ event.dataTransfer.setDragImage(this.$refs.draggableDataTransfer as Element, 0, 0); } - this.$data.dragging = true; - this.$data.draggablePosition = { x, y }; + this.dragging = true; + this.draggablePosition = { x, y }; }, onDragOver(event: DragEvent): void { if (!this.dragging || event.pageX === 0 && event.pageY === 0) { @@ -110,7 +123,7 @@ export default Vue.extend({ const [x,y] = getNewNodePosition([], [event.pageX - NODE_SIZE / 2, event.pageY - NODE_SIZE / 2]); - this.$data.draggablePosition = { x, y }; + this.draggablePosition = { x, y }; }, onDragEnd(event: DragEvent): void { this.$emit('dragend', { @@ -118,12 +131,14 @@ export default Vue.extend({ // Safari and Firefox return incorrect values for "dragend" event, // override with last known value - pageX: this.$data.draggablePosition.x, - pageY: this.$data.draggablePosition.y, + pageX: this.draggablePosition.x, + pageY: this.draggablePosition.y, }); - this.$data.dragging = false; - this.$data.draggablePosition = { x: -100, y: -100 }; + this.dragging = false; + setTimeout(() => { + this.draggablePosition = { x: -100, y: -100 }; + }, 300); }, }, }); @@ -192,3 +207,20 @@ export default Vue.extend({ height: 1px; } + + diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 13149a3b6641d..0bcd5b44ae06f 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -184,8 +184,8 @@ import '../plugins/N8nCustomConnectorType'; import '../plugins/PlusEndpointType'; interface AddNodeOptions { - openDataDisplay?: boolean; position?: XYPosition; + dragAndDrop?: boolean; } export default mixins( @@ -1243,6 +1243,7 @@ export default mixins( nodeTypeDragEnd ({ nodeTypeName, event }: { nodeTypeName: string, event: DragEvent }) { this.addNodeButton(nodeTypeName, { position: this.getMousePositionWithinNodeView(event), + dragAndDrop: true, }); this.createNodeActive = false; }, @@ -1383,7 +1384,11 @@ export default mixins( this.$store.commit('setStateDirty', true); this.$externalHooks().run('nodeView.addNodeButton', { nodeTypeName }); - this.$telemetry.trackNodesPanel('nodeView.addNodeButton', { node_type: nodeTypeName, workflow_id: this.$store.getters.workflowId }); + this.$telemetry.trackNodesPanel('nodeView.addNodeButton', { + node_type: nodeTypeName, + workflow_id: this.$store.getters.workflowId, + drag_and_drop: options.dragAndDrop, + } as IDataObject); // Automatically deselect all nodes and select the current one and also active // current node @@ -1426,11 +1431,7 @@ export default mixins( this.__addConnection(connectionData, true); }, - async addNodeButton (nodeTypeName: string, options: AddNodeOptions = { - openDataDisplay: true, - }) { - console.log(options.position); - + async addNodeButton (nodeTypeName: string, options: AddNodeOptions = {}) { if (this.editAllowedCheck() === false) { return; }