From baeeca9702a7c76356293edd3ec027d52eadf91c Mon Sep 17 00:00:00 2001 From: navaneeth Date: Thu, 3 Jun 2021 22:29:29 +0530 Subject: [PATCH] Fixed bug that caused incorrect layout being repositioned --- frontend/src/Editor/Container.jsx | 10 +++++----- frontend/src/Editor/DraggableBox.jsx | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/Editor/Container.jsx b/frontend/src/Editor/Container.jsx index 1757f36ff6..35e6ee4ec8 100644 --- a/frontend/src/Editor/Container.jsx +++ b/frontend/src/Editor/Container.jsx @@ -93,7 +93,7 @@ export const Container = ({ } let layouts = item['layouts']; - const currentLayoutOptions = layouts ? layouts[currentLayout] : {}; + const currentLayoutOptions = layouts ? layouts[item.currentLayout] : {}; let componentData = {}; let componentMeta = {}; @@ -129,8 +129,8 @@ export const Container = ({ ...boxes[id], layouts: { ...boxes[id]['layouts'], - [currentLayout]: { - ...boxes[id]['layouts'][currentLayout], + [item.currentLayout]: { + ...boxes[id]['layouts'][item.currentLayout], top: top, left: left, } @@ -165,7 +165,7 @@ export const Container = ({ [id]: { component: componentData, layouts: { - [currentLayout]: { + [item.currentLayout]: { top: top, left: left, width: componentMeta.defaultSize.width, @@ -291,7 +291,7 @@ export const Container = ({ configHandleClicked, removeComponent, currentLayout, - scaleValue + scaleValue }} /> } diff --git a/frontend/src/Editor/DraggableBox.jsx b/frontend/src/Editor/DraggableBox.jsx index 8b97bbcc41..fe9a49e4d0 100644 --- a/frontend/src/Editor/DraggableBox.jsx +++ b/frontend/src/Editor/DraggableBox.jsx @@ -79,13 +79,13 @@ export const DraggableBox = function DraggableBox({ () => ({ type: ItemTypes.BOX, item: { - id, title, component, zoomLevel, parent, layouts + id, title, component, zoomLevel, parent, layouts, currentLayout }, collect: (monitor) => ({ isDragging: monitor.isDragging() }) }), - [id, title, component, index, zoomLevel, parent, layouts] + [id, title, component, index, zoomLevel, parent, layouts, currentLayout] ); useEffect(() => {