mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
fix(editor): Focus on selection when clicking 'tidy up' (#19303)
This commit is contained in:
@@ -35,7 +35,7 @@ import type {
|
||||
ViewportTransform,
|
||||
XYPosition,
|
||||
} 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 { onKeyDown, onKeyUp, useThrottleFn } from '@vueuse/core';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
@@ -149,6 +149,7 @@ const {
|
||||
removeSelectedNodes,
|
||||
viewportRef,
|
||||
fitView,
|
||||
fitBounds,
|
||||
zoomIn,
|
||||
zoomOut,
|
||||
zoomTo,
|
||||
@@ -635,6 +636,10 @@ function onClickPane(event: MouseEvent) {
|
||||
emit('click:pane', getProjectedPosition(event));
|
||||
}
|
||||
|
||||
async function onFitBounds(nodes: GraphNode[]) {
|
||||
await fitBounds(getRectOfNodes(nodes), { padding: 2 });
|
||||
}
|
||||
|
||||
async function onFitView() {
|
||||
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 });
|
||||
|
||||
if (!applyOnSelection) {
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
if (applyOnSelection) {
|
||||
await onFitBounds(selectedNodes.value);
|
||||
} else {
|
||||
await onFitView();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user