mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 01:18:23 +00:00
Added a logic to place form inside the parent component
This commit is contained in:
parent
9bba334441
commit
a909ae76d4
1 changed files with 33 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue