fix(editor): Fix NDV panels size on narrow screens

This commit is contained in:
Milorad Filipovic 2025-03-05 14:58:45 +01:00
parent 8790a0df3d
commit 85ea9977b1
No known key found for this signature in database
2 changed files with 28 additions and 18 deletions

View file

@ -43,6 +43,7 @@ const props = defineProps<Props>();
const isDragging = ref<boolean>(false);
const initialized = ref<boolean>(false);
const containerWidth = ref<number>(uiStore.appGridWidth);
const emit = defineEmits<{
init: [{ position: number }];
@ -84,28 +85,36 @@ onBeforeUnmount(() => {
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) => {
const minRelativeWidth = pxToRelativeWidth(MIN_PANEL_WIDTH);
const isBelowMinWidthMainPanel = mainPanelDimensions.value.relativeWidth < minRelativeWidth;
// Prevent the panel resizing below MIN_PANEL_WIDTH while maintain position
if (isBelowMinWidthMainPanel) {
setMainPanelWidth(minRelativeWidth);
}
// Prevent the panel resizing below MIN_PANEL_WIDTH whhile maintaing position
if (isBelowMinWidthMainPanel) {
setMainPanelWidth(minRelativeWidth);
}
const isBelowMinLeft = minimumLeftPosition.value > mainPanelDimensions.value.relativeLeft;
const isMaxRight = maximumRightPosition.value > mainPanelDimensions.value.relativeRight;
const isBelowMinLeft = minimumLeftPosition.value > mainPanelDimensions.value.relativeLeft;
const isMaxRight = maximumRightPosition.value > mainPanelDimensions.value.relativeRight;
// When user is resizing from non-supported view(sub ~488px) we need to refit the panels
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
if (width > MIN_WINDOW_WIDTH && isBelowMinLeft && isMaxRight) {
setMainPanelWidth(minRelativeWidth);
setPositions(getInitialLeftPosition(mainPanelDimensions.value.relativeWidth));
}
setPositions(mainPanelDimensions.value.relativeLeft);
});
setPositions(mainPanelDimensions.value.relativeLeft);
},
);
const currentNodePaneType = computed((): MainPanelType => {
if (!hasInputSlot.value) return 'inputless';

View file

@ -706,6 +706,7 @@ onBeforeUnmount(() => {
<template>
<el-dialog
id="ndv"
:model-value="(!!activeNode || renaming) && !isActiveStickyNode"
:before-close="close"
:show-close="false"