From 6712e58f63c7c1f5ebce52f30a37e2ed72b49a32 Mon Sep 17 00:00:00 2001 From: Dave Myron Date: Sat, 18 Jun 2022 04:47:56 -0700 Subject: [PATCH] Take canvas offsets into account when dropping a new block on the canvas. (#4387) Take canvas offsets into account when dropping a new block on the canvas. Relates to #2824 Co-authored-by: Artur Arseniev --- src/utils/Droppable.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/utils/Droppable.js b/src/utils/Droppable.js index 7ad8ac497..721d039b4 100644 --- a/src/utils/Droppable.js +++ b/src/utils/Droppable.js @@ -112,8 +112,13 @@ export default class Droppable { let comp; if (!cancelled) { comp = wrapper.append(content)[0]; - const { left, top, position } = target.getStyle(); - comp.addStyle({ left, top, position }); + const canvasOffset = editor.Canvas.getOffset(); + const { top, left, position } = target.getStyle(); + comp.addStyle({ + left: parseFloat(left) - canvasOffset.left + 'px', + top: parseFloat(top) - canvasOffset.top + 'px', + position, + }); } this.handleDragEnd(comp, dt); target.remove();