Skip to content

Commit

Permalink
fix(editor): Fix node position not getting set when dragging selectio…
Browse files Browse the repository at this point in the history
…n on new canvas (#11871)
  • Loading branch information
alexgrozav authored Nov 25, 2024
1 parent 91d1bd8 commit 595de81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions packages/editor-ui/src/components/canvas/Canvas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ describe('Canvas', () => {
});

it('should handle `update:nodes:position` event', async () => {
vi.useFakeTimers();

const nodes = [createCanvasNodeElement()];
const { container, emitted } = renderComponent({
props: {
Expand All @@ -112,8 +110,6 @@ describe('Canvas', () => {
});
await fireEvent.mouseUp(node, { view: window });

vi.advanceTimersByTime(250); // Event debounce time

expect(emitted()['update:nodes:position']).toEqual([
[
[
Expand Down
5 changes: 5 additions & 0 deletions packages/editor-ui/src/components/canvas/Canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ function onNodeDragStop(event: NodeDragEvent) {
onUpdateNodesPosition(event.nodes.map(({ id, position }) => ({ id, position })));
}
function onSelectionDragStop(event: NodeDragEvent) {
onUpdateNodesPosition(event.nodes.map(({ id, position }) => ({ id, position })));
}
function onSetNodeActive(id: string) {
props.eventBus.emit('nodes:action', { ids: [id], action: 'update:node:active' });
emit('update:node:active', id);
Expand Down Expand Up @@ -644,6 +648,7 @@ provide(CanvasKey, {
@move-start="onPaneMoveStart"
@move-end="onPaneMoveEnd"
@node-drag-stop="onNodeDragStop"
@selection-drag-stop="onSelectionDragStop"
>
<template #node-canvas-node="nodeProps">
<Node
Expand Down

0 comments on commit 595de81

Please sign in to comment.