From 3822be76a840bb098fb1dbd53fa90158fcaf5d67 Mon Sep 17 00:00:00 2001 From: Eva Date: Mon, 4 Apr 2022 17:15:23 +0200 Subject: [PATCH] :bug: Fix send to back several shapes at a time --- CHANGES.md | 1 + frontend/src/app/main/data/workspace.cljs | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b947696354..ff08da4326 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -43,6 +43,7 @@ ### :bug: Bugs fixed +- Fix send to back several shapes at a time [Taiga #3077](https://tree.taiga.io/project/penpot/issue/3077) - Fix duplicate multi selected elements [Taiga #3155](https://tree.taiga.io/project/penpot/issue/3155) - Fix add fills to artboard modify children [Taiga #3151](https://tree.taiga.io/project/penpot/issue/3151) - Avoid numeric inputs to allow big numbers [Taiga #2858](https://tree.taiga.io/project/penpot/issue/2858) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index fbf2017608..4f0e74ecb4 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -578,19 +578,20 @@ (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) - selected-shapes (->> (wsh/lookup-selected state) - (map (d/getf objects))) + selected-ids (wsh/lookup-selected state) + selected-shapes (map (d/getf objects) selected-ids) move-shape (fn [changes shape] (let [parent (get objects (:parent-id shape)) sibling-ids (:shapes parent) current-index (d/index-of sibling-ids (:id shape)) + index-in-selection (d/index-of selected-ids (:id shape)) new-index (case loc :top (count sibling-ids) :down (max 0 (- current-index 1)) :up (min (count sibling-ids) (+ (inc current-index) 1)) - :bottom 0)] + :bottom index-in-selection)] (pcb/change-parent changes (:id parent) [shape] @@ -631,11 +632,11 @@ (pcb/update-shapes shapes-to-detach (fn [shape] (assoc shape :component-id nil - :component-file nil - :component-root? nil - :remote-synced? nil - :shape-ref nil - :touched nil))) + :component-file nil + :component-root? nil + :remote-synced? nil + :shape-ref nil + :touched nil))) ; Make non root a component moved inside another one (pcb/update-shapes shapes-to-deroot