diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 465cadcdfb..5e6c90faf5 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -13710,6 +13710,23 @@ "react-draggable": "^4.0.3" } }, + "react-rnd": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/react-rnd/-/react-rnd-10.3.0.tgz", + "integrity": "sha512-v+0TRPIaRWY25TYv02vLQHYpACbkX+4xKvsyIrUEy4bMpq0bP1oEiaxTorp0Xn72IVv0QZV1vOnZimgTEB/skw==", + "requires": { + "re-resizable": "6.9.0", + "react-draggable": "4.4.3", + "tslib": "2.2.0" + }, + "dependencies": { + "tslib": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz", + "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==" + } + } + }, "react-router": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index bc48caf87d..526df3d1f2 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -38,6 +38,7 @@ "react-loading-skeleton": "^2.2.0", "react-plotly.js": "^2.5.1", "react-resizable": "^1.11.1", + "react-rnd": "^10.3.0", "react-router-dom": "^5.0.0", "react-scripts": "3.4.3", "react-select-search": "^3.0.5", diff --git a/frontend/src/Editor/Box.jsx b/frontend/src/Editor/Box.jsx index 5fb22b77da..e1647ab99a 100644 --- a/frontend/src/Editor/Box.jsx +++ b/frontend/src/Editor/Box.jsx @@ -85,7 +85,7 @@ export const Box = function Box({ containerProps={containerProps} > ) : ( -
+
- setResizing(true)} - handleClasses={resizerClasses} - handleStyles={resizerStyles} - onResizeStop={(e, direction, ref, d) => { + resizeHandleClasses={resizerClasses} + resizeHandleStyles={resizerStyles} + disableDragging={true} + onResizeStop={(e, direction, ref, d, position) => { setResizing(false); - onResizeStop(id, width, height, e, direction, ref, d); + onResizeStop(id, e, direction, ref, d, position); }} >
@@ -156,7 +160,7 @@ export const DraggableBox = function DraggableBox({ containerProps={containerProps} />
-
+
) : (
diff --git a/frontend/src/Editor/SubContainer.jsx b/frontend/src/Editor/SubContainer.jsx index de97ee7a7d..eeffef45cc 100644 --- a/frontend/src/Editor/SubContainer.jsx +++ b/frontend/src/Editor/SubContainer.jsx @@ -164,14 +164,24 @@ export const SubContainer = ({ [moveBox] ); - function onResizeStop(id, width, height, e, direction, ref, d) { + function onResizeStop(id, e, direction, ref, d, position) { const deltaWidth = d.width; const deltaHeight = d.height; + let { x, y } = position; + + let { left, top, width, height } = boxes[id]; + + top = y; + left = x; + + width = width + deltaWidth; + height = height + deltaHeight + setBoxes( update(boxes, { [id]: { - $merge: { width: deltaWidth + width, height: deltaHeight + height } + $merge: { width, height, top, left } } }) );