From bc835e9dac5c860f12cab28b570acfc576562642 Mon Sep 17 00:00:00 2001 From: Johnson Cherian Date: Thu, 11 Jan 2024 02:55:45 +0530 Subject: [PATCH] fix: prevent widgets from havin negative top position --- frontend/src/Editor/Container.jsx | 7 +++++++ frontend/src/Editor/DragContainer.jsx | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/frontend/src/Editor/Container.jsx b/frontend/src/Editor/Container.jsx index 2e7f959fbe..3db024b275 100644 --- a/frontend/src/Editor/Container.jsx +++ b/frontend/src/Editor/Container.jsx @@ -357,6 +357,9 @@ export const Container = ({ const newWidth = (width * noOfGrids) / _canvasWidth; gw = gw ? gw : gridWidth; const parent = boxes[id]?.component?.parent; + if (y < 0) { + y = 0; + } if (parent) { const parentElem = document.getElementById(`canvas-${parent}`); const parentId = parent.includes('-') ? parent?.split('-').slice(0, -1).join('-') : parent; @@ -425,6 +428,10 @@ export const Container = ({ } } + if (y < 0) { + y = 0; + } + if (parent) { const parentElem = document.getElementById(`canvas-${parent}`); const parentId = parent.includes('-') ? parent?.split('-').slice(0, -1).join('-') : parent; diff --git a/frontend/src/Editor/DragContainer.jsx b/frontend/src/Editor/DragContainer.jsx index b8b7bdb25d..0805d1bd06 100644 --- a/frontend/src/Editor/DragContainer.jsx +++ b/frontend/src/Editor/DragContainer.jsx @@ -772,6 +772,10 @@ export default function DragContainer({ width, } = lastEvent; + if (top < 0) { + top = 0; + } + let draggedOverElemId = i.parent; const parentComponent = boxes.find((box) => box.id === i.parent); const parentComponentType = parentComponent?.component?.component;