Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Fix node position not getting set when dragging selection on new canvas #11871

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading