From a909ae76d449610353ac02a749e5211e3c767a07 Mon Sep 17 00:00:00 2001 From: Kavin Venkatachalam Date: Fri, 19 Jan 2024 15:21:39 +0530 Subject: [PATCH] Added a logic to place form inside the parent component --- frontend/src/Editor/SubContainer.jsx | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/frontend/src/Editor/SubContainer.jsx b/frontend/src/Editor/SubContainer.jsx index df462db1da..5bd407531c 100644 --- a/frontend/src/Editor/SubContainer.jsx +++ b/frontend/src/Editor/SubContainer.jsx @@ -158,6 +158,36 @@ export const SubContainer = ({ const containerWidth = getContainerCanvasWidth(); + const placeComponentInsideParent = (newComponent, canvasBoundingRect) => { + const layout = newComponent?.layout?.desktop; + let newWidth = layout.width, + newHeight = layout.top + layout.height; + if (layout) { + if (newWidth + layout.left >= 43) { + newWidth = 43 - layout.left; + } + if (newHeight > canvasBoundingRect.height) { + newHeight = canvasBoundingRect.height - layout.top; + } + return { + ...newComponent, + layout: { + desktop: { + ...layout, + height: newHeight, + width: newWidth, + }, + mobile: { + ...layout, + height: newHeight, + width: newWidth, + }, + }, + }; + } + return newComponent; + }; + const placeComponentInsideListView = (newComponent, canvasBoundingRect) => { const layout = newComponent?.layout?.desktop; if (layout && canvasBoundingRect.height <= layout.top) { @@ -409,6 +439,9 @@ export const SubContainer = ({ if (parentComp === 'Listview') { newComponent = placeComponentInsideListView(newComponent, canvasBoundingRect); } + if (componentMeta.component === 'Form') { + newComponent = placeComponentInsideParent(newComponent, canvasBoundingRect); + } setBoxes({ ...boxes,