From f11c782c0fa0edb4469fe8fb7e98b683ea7f29c2 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 24 Mar 2023 15:09:40 +0100 Subject: [PATCH] :bug: Fix problem when copy/pasting shapes --- CHANGES.md | 1 + frontend/src/app/main/data/workspace.cljs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 706c30f83..be95c060f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -54,6 +54,7 @@ - Fix problem with guides not showing when moving over nested frames [Taiga #4905](https://tree.taiga.io/project/penpot/issue/4905) - Fix change email and password for users signed in via social login [Taiga #4273](https://tree.taiga.io/project/penpot/issue/4273) - Fix drag and drop files from browser or file explorer under circumstances [Taiga #5054](https://tree.taiga.io/project/penpot/issue/5054) +- Fix problem when copy/pasting shapes [Taiga #4931](https://tree.taiga.io/project/penpot/issue/4931) ### :heart: Community contributions by (Thank you!) - To @ondrejkonec: for contributing to the code with: diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 816ed7e7e..a24dd1c30 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1326,14 +1326,19 @@ res))) (maybe-translate [shape objects selected+children] - (let [root-frame-id (cph/get-shape-id-root-frame objects (:id shape))] - (if (and (not (cph/root-frame? shape)) - (not (contains? selected+children root-frame-id))) - ;; When the parent frame is not selected we change to relative - ;; coordinates + (let [frame-id (:frame-id shape) + root-frame-id (cph/get-shape-id-root-frame objects (:id shape))] + (cond + (cph/root-frame? shape) shape + (contains? selected+children root-frame-id) shape + + (cph/frame-shape? shape) (let [frame (get objects root-frame-id)] (gsh/translate-to-frame shape frame)) - shape))) + + :else + (let [frame (get objects frame-id)] + (gsh/translate-to-frame shape frame))))) (on-copy-error [error] (js/console.error "Clipboard blocked:" error)