Fixed bug that caused incorrect layout being repositioned

This commit is contained in:
navaneeth 2021-06-03 22:29:29 +05:30
parent 4700063eef
commit baeeca9702
2 changed files with 7 additions and 7 deletions

View file

@ -93,7 +93,7 @@ export const Container = ({
} }
let layouts = item['layouts']; let layouts = item['layouts'];
const currentLayoutOptions = layouts ? layouts[currentLayout] : {}; const currentLayoutOptions = layouts ? layouts[item.currentLayout] : {};
let componentData = {}; let componentData = {};
let componentMeta = {}; let componentMeta = {};
@ -129,8 +129,8 @@ export const Container = ({
...boxes[id], ...boxes[id],
layouts: { layouts: {
...boxes[id]['layouts'], ...boxes[id]['layouts'],
[currentLayout]: { [item.currentLayout]: {
...boxes[id]['layouts'][currentLayout], ...boxes[id]['layouts'][item.currentLayout],
top: top, top: top,
left: left, left: left,
} }
@ -165,7 +165,7 @@ export const Container = ({
[id]: { [id]: {
component: componentData, component: componentData,
layouts: { layouts: {
[currentLayout]: { [item.currentLayout]: {
top: top, top: top,
left: left, left: left,
width: componentMeta.defaultSize.width, width: componentMeta.defaultSize.width,
@ -291,7 +291,7 @@ export const Container = ({
configHandleClicked, configHandleClicked,
removeComponent, removeComponent,
currentLayout, currentLayout,
scaleValue scaleValue
}} }}
/> />
} }

View file

@ -79,13 +79,13 @@ export const DraggableBox = function DraggableBox({
() => ({ () => ({
type: ItemTypes.BOX, type: ItemTypes.BOX,
item: { item: {
id, title, component, zoomLevel, parent, layouts id, title, component, zoomLevel, parent, layouts, currentLayout
}, },
collect: (monitor) => ({ collect: (monitor) => ({
isDragging: monitor.isDragging() isDragging: monitor.isDragging()
}) })
}), }),
[id, title, component, index, zoomLevel, parent, layouts] [id, title, component, index, zoomLevel, parent, layouts, currentLayout]
); );
useEffect(() => { useEffect(() => {