Added a logic to place form inside the parent component

This commit is contained in:
Kavin Venkatachalam 2024-01-19 15:21:39 +05:30
parent 9bba334441
commit a909ae76d4

View file

@ -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,