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): Add missing control button events to new canvas (no-changelog) #10471

Merged
merged 2 commits into from
Aug 19, 2024
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
9 changes: 5 additions & 4 deletions packages/editor-ui/src/components/canvas/Canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ function emitWithLastSelectedNode(emitFn: (id: string) => void) {
* View
*/

const zoom = ref(1);
const defaultZoom = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this change was already in the other PR?

const zoom = ref(defaultZoom);

function onClickPane(event: MouseEvent) {
const bounds = viewportRef.value?.getBoundingClientRect() ?? { left: 0, top: 0 };
Expand All @@ -282,7 +283,7 @@ function onClickPane(event: MouseEvent) {
}

async function onFitView() {
await fitView({ maxZoom: 1.2, padding: 0.2 });
await fitView({ maxZoom: defaultZoom, padding: 0.2 });
}

async function onZoomTo(zoomLevel: number) {
Expand All @@ -298,7 +299,7 @@ async function onZoomOut() {
}

async function onResetZoom() {
await onZoomTo(1);
await onZoomTo(defaultZoom);
}

function onViewportChange(viewport: ViewportTransform) {
Expand Down Expand Up @@ -469,7 +470,7 @@ watch(() => props.readOnly, setReadonly, {
:position="controlsPosition"
:show-interactive="false"
:zoom="zoom"
@fit-view="onFitView"
@zoom-to-fit="onFitView"
@zoom-in="onZoomIn"
@zoom-out="onZoomOut"
@reset-zoom="onResetZoom"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,28 @@ const props = withDefaults(

const emit = defineEmits<{
'reset-zoom': [];
'zoom-in': [];
'zoom-out': [];
'zoom-to-fit': [];
}>();

const isResetZoomVisible = computed(() => props.zoom !== 1);

function onResetZoom() {
emit('reset-zoom');
}

function onZoomIn() {
emit('zoom-in');
}

function onZoomOut() {
emit('zoom-out');
}

function onZoomToFit() {
emit('zoom-to-fit');
}
</script>
<template>
<Controls :show-zoom="false" :show-fit-view="false">
Expand All @@ -33,6 +48,7 @@ function onResetZoom() {
size="large"
icon="search-plus"
data-test-id="zoom-in-button"
@click="onZoomIn"
/>
</KeyboardShortcutTooltip>
<KeyboardShortcutTooltip
Expand All @@ -44,13 +60,20 @@ function onResetZoom() {
size="large"
icon="search-minus"
data-test-id="zoom-out-button"
@click="onZoomOut"
/>
</KeyboardShortcutTooltip>
<KeyboardShortcutTooltip
:label="$locale.baseText('nodeView.zoomToFit')"
:shortcut="{ keys: ['1'] }"
>
<N8nIconButton type="tertiary" size="large" icon="expand" data-test-id="zoom-to-fit" />
<N8nIconButton
type="tertiary"
size="large"
icon="expand"
data-test-id="zoom-to-fit"
@click="onZoomToFit"
/>
</KeyboardShortcutTooltip>
<KeyboardShortcutTooltip
v-if="isResetZoomVisible"
Expand All @@ -72,5 +95,6 @@ function onResetZoom() {
.vue-flow__controls {
display: flex;
gap: var(--spacing-xs);
box-shadow: none;
}
</style>
Loading