Skip to content

Commit

Permalink
fix(editor): Override selected nodes on single click without Meta/Ctr…
Browse files Browse the repository at this point in the history
…l key (#12549)
  • Loading branch information
alexgrozav authored Jan 10, 2025
1 parent 92d3de2 commit 02c2d5e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/editor-ui/src/components/canvas/Canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import type {
CanvasEventBusEvents,
ConnectStartEvent,
} from '@/types';
import type { Connection, XYPosition, NodeDragEvent, GraphNode } from '@vue-flow/core';
import type {
Connection,
XYPosition,
NodeDragEvent,
NodeMouseEvent,
GraphNode,
} from '@vue-flow/core';
import { useVueFlow, VueFlow, PanelPosition, MarkerType } from '@vue-flow/core';
import { MiniMap } from '@vue-flow/minimap';
import Node from './elements/nodes/CanvasNode.vue';
Expand Down Expand Up @@ -272,6 +278,14 @@ function onNodeDragStop(event: NodeDragEvent) {
onUpdateNodesPosition(event.nodes.map(({ id, position }) => ({ id, position })));
}
function onNodeClick({ event, node }: NodeMouseEvent) {
if (event.ctrlKey || event.metaKey || selectedNodes.value.length < 2) {
return;
}
onSelectNodes({ ids: [node.id] });
}
function onSelectionDragStop(event: NodeDragEvent) {
onUpdateNodesPosition(event.nodes.map(({ id, position }) => ({ id, position })));
}
Expand Down Expand Up @@ -676,6 +690,7 @@ provide(CanvasKey, {
@move-start="onPaneMoveStart"
@move-end="onPaneMoveEnd"
@node-drag-stop="onNodeDragStop"
@node-click="onNodeClick"
@selection-drag-stop="onSelectionDragStop"
@dragover="onDragOver"
@drop="onDrop"
Expand Down

0 comments on commit 02c2d5e

Please sign in to comment.