mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(editor): Focus on selection when clicking 'tidy up' (#19303)
This commit is contained in:
@@ -35,7 +35,7 @@ import type {
|
|||||||
ViewportTransform,
|
ViewportTransform,
|
||||||
XYPosition,
|
XYPosition,
|
||||||
} from '@vue-flow/core';
|
} from '@vue-flow/core';
|
||||||
import { MarkerType, PanelPosition, useVueFlow, VueFlow } from '@vue-flow/core';
|
import { getRectOfNodes, MarkerType, PanelPosition, useVueFlow, VueFlow } from '@vue-flow/core';
|
||||||
import { MiniMap } from '@vue-flow/minimap';
|
import { MiniMap } from '@vue-flow/minimap';
|
||||||
import { onKeyDown, onKeyUp, useThrottleFn } from '@vueuse/core';
|
import { onKeyDown, onKeyUp, useThrottleFn } from '@vueuse/core';
|
||||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||||
@@ -149,6 +149,7 @@ const {
|
|||||||
removeSelectedNodes,
|
removeSelectedNodes,
|
||||||
viewportRef,
|
viewportRef,
|
||||||
fitView,
|
fitView,
|
||||||
|
fitBounds,
|
||||||
zoomIn,
|
zoomIn,
|
||||||
zoomOut,
|
zoomOut,
|
||||||
zoomTo,
|
zoomTo,
|
||||||
@@ -635,6 +636,10 @@ function onClickPane(event: MouseEvent) {
|
|||||||
emit('click:pane', getProjectedPosition(event));
|
emit('click:pane', getProjectedPosition(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onFitBounds(nodes: GraphNode[]) {
|
||||||
|
await fitBounds(getRectOfNodes(nodes), { padding: 2 });
|
||||||
|
}
|
||||||
|
|
||||||
async function onFitView() {
|
async function onFitView() {
|
||||||
await fitView({ maxZoom: defaultZoom, padding: 0.2 });
|
await fitView({ maxZoom: defaultZoom, padding: 0.2 });
|
||||||
}
|
}
|
||||||
@@ -768,8 +773,10 @@ async function onTidyUp(payload: CanvasEventBusEvents['tidyUp']) {
|
|||||||
|
|
||||||
emit('tidy-up', { result, target, source: payload.source }, { trackEvents: payload.trackEvents });
|
emit('tidy-up', { result, target, source: payload.source }, { trackEvents: payload.trackEvents });
|
||||||
|
|
||||||
if (!applyOnSelection) {
|
await nextTick();
|
||||||
await nextTick();
|
if (applyOnSelection) {
|
||||||
|
await onFitBounds(selectedNodes.value);
|
||||||
|
} else {
|
||||||
await onFitView();
|
await onFitView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user