0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 08:29:42 -05:00

🐛 Fix cut/paste component inside a board

This commit is contained in:
Alejandro Alonso 2024-02-09 09:41:23 +01:00 committed by Andrés Moya
parent c4e707d5a2
commit 5cbb3f76c7

View file

@ -258,9 +258,12 @@
parent (get-in page [:objects parent-id])
main-inst (get-in component [:objects (:main-instance-id component)])
inside-component? (some? (ctn/get-instance-root (:objects page) parent))
origin-frame (get-in page [:objects (:frame-id main-inst)])
;; We are using a deleted component andit's coordenates are absolute, we must adjust them to its containing frame to adjust the delta
delta (gpt/subtract delta (-> origin-frame :selrect gpt/point))
shapes (cfh/get-children-with-self (:objects component) (:main-instance-id component))
shapes (map #(gsh/move % delta) shapes)
first-shape (cond-> (first shapes)
(not (nil? parent-id))
(assoc :parent-id parent-id)