mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Fix NDV panels size on narrow screens
This commit is contained in:
parent
8790a0df3d
commit
85ea9977b1
|
@ -43,6 +43,7 @@ const props = defineProps<Props>();
|
||||||
|
|
||||||
const isDragging = ref<boolean>(false);
|
const isDragging = ref<boolean>(false);
|
||||||
const initialized = ref<boolean>(false);
|
const initialized = ref<boolean>(false);
|
||||||
|
const containerWidth = ref<number>(uiStore.appGridWidth);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
init: [{ position: number }];
|
init: [{ position: number }];
|
||||||
|
@ -84,28 +85,36 @@ onBeforeUnmount(() => {
|
||||||
ndvEventBus.off('setPositionByName', setPositionByName);
|
ndvEventBus.off('setPositionByName', setPositionByName);
|
||||||
});
|
});
|
||||||
|
|
||||||
const containerWidth = computed(() => uiStore.appGridWidth);
|
watch(
|
||||||
|
() => uiStore.appGridWidth,
|
||||||
|
(width) => {
|
||||||
|
const ndv = document.getElementById('ndv');
|
||||||
|
if (ndv) {
|
||||||
|
const { width: ndvWidth } = ndv.getBoundingClientRect();
|
||||||
|
containerWidth.value = ndvWidth;
|
||||||
|
} else {
|
||||||
|
containerWidth.value = width;
|
||||||
|
}
|
||||||
|
const minRelativeWidth = pxToRelativeWidth(MIN_PANEL_WIDTH);
|
||||||
|
const isBelowMinWidthMainPanel = mainPanelDimensions.value.relativeWidth < minRelativeWidth;
|
||||||
|
|
||||||
watch(containerWidth, (width) => {
|
// Prevent the panel resizing below MIN_PANEL_WIDTH while maintain position
|
||||||
const minRelativeWidth = pxToRelativeWidth(MIN_PANEL_WIDTH);
|
if (isBelowMinWidthMainPanel) {
|
||||||
const isBelowMinWidthMainPanel = mainPanelDimensions.value.relativeWidth < minRelativeWidth;
|
setMainPanelWidth(minRelativeWidth);
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent the panel resizing below MIN_PANEL_WIDTH whhile maintaing position
|
const isBelowMinLeft = minimumLeftPosition.value > mainPanelDimensions.value.relativeLeft;
|
||||||
if (isBelowMinWidthMainPanel) {
|
const isMaxRight = maximumRightPosition.value > mainPanelDimensions.value.relativeRight;
|
||||||
setMainPanelWidth(minRelativeWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
const isBelowMinLeft = minimumLeftPosition.value > mainPanelDimensions.value.relativeLeft;
|
// When user is resizing from non-supported view(sub ~488px) we need to refit the panels
|
||||||
const isMaxRight = maximumRightPosition.value > mainPanelDimensions.value.relativeRight;
|
if (width > MIN_WINDOW_WIDTH && isBelowMinLeft && isMaxRight) {
|
||||||
|
setMainPanelWidth(minRelativeWidth);
|
||||||
|
setPositions(getInitialLeftPosition(mainPanelDimensions.value.relativeWidth));
|
||||||
|
}
|
||||||
|
|
||||||
// When user is resizing from non-supported view(sub ~488px) we need to refit the panels
|
setPositions(mainPanelDimensions.value.relativeLeft);
|
||||||
if (width > MIN_WINDOW_WIDTH && isBelowMinLeft && isMaxRight) {
|
},
|
||||||
setMainPanelWidth(minRelativeWidth);
|
);
|
||||||
setPositions(getInitialLeftPosition(mainPanelDimensions.value.relativeWidth));
|
|
||||||
}
|
|
||||||
|
|
||||||
setPositions(mainPanelDimensions.value.relativeLeft);
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentNodePaneType = computed((): MainPanelType => {
|
const currentNodePaneType = computed((): MainPanelType => {
|
||||||
if (!hasInputSlot.value) return 'inputless';
|
if (!hasInputSlot.value) return 'inputless';
|
||||||
|
|
|
@ -706,6 +706,7 @@ onBeforeUnmount(() => {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
|
id="ndv"
|
||||||
:model-value="(!!activeNode || renaming) && !isActiveStickyNode"
|
:model-value="(!!activeNode || renaming) && !isActiveStickyNode"
|
||||||
:before-close="close"
|
:before-close="close"
|
||||||
:show-close="false"
|
:show-close="false"
|
||||||
|
|
Loading…
Reference in a new issue