mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
Placed components inside the listView if it is dropped outside the first row
This commit is contained in:
parent
149e94f22f
commit
d5672730c1
1 changed files with 33 additions and 1 deletions
|
|
@ -158,6 +158,34 @@ export const SubContainer = ({
|
|||
|
||||
const containerWidth = getContainerCanvasWidth();
|
||||
|
||||
const placeComponentInsideListView = (newComponent, canvasBoundingRect) => {
|
||||
const layout = newComponent?.layout?.desktop;
|
||||
if (layout && canvasBoundingRect.height <= layout.top) {
|
||||
let newTop = canvasBoundingRect.height - layout.height,
|
||||
newHeight = layout.height;
|
||||
if (newTop < 0) {
|
||||
newTop = 0;
|
||||
newHeight = canvasBoundingRect.height;
|
||||
}
|
||||
return {
|
||||
...newComponent,
|
||||
layout: {
|
||||
desktop: {
|
||||
...layout,
|
||||
top: newTop,
|
||||
height: newHeight,
|
||||
},
|
||||
mobile: {
|
||||
...layout,
|
||||
top: newTop,
|
||||
height: newHeight,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
return newComponent;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setSubContainerWidths(parent, containerWidth / noOfGrids);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
|
@ -367,7 +395,7 @@ export const SubContainer = ({
|
|||
: 'Kanban_card'
|
||||
: parentComponent.component;
|
||||
if (!restrictedWidgetsObj[parentComp].includes(componentMeta?.component)) {
|
||||
const newComponent = addNewWidgetToTheEditor(
|
||||
let newComponent = addNewWidgetToTheEditor(
|
||||
componentMeta,
|
||||
monitor,
|
||||
boxes,
|
||||
|
|
@ -378,6 +406,10 @@ export const SubContainer = ({
|
|||
true
|
||||
);
|
||||
|
||||
if (parentComp === 'Listview') {
|
||||
newComponent = placeComponentInsideListView(newComponent, canvasBoundingRect);
|
||||
}
|
||||
|
||||
setBoxes({
|
||||
...boxes,
|
||||
[newComponent.id]: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue