From 02ea0374a38bca09013ba5085d9d813c2e053b40 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 4 Apr 2024 17:31:52 +0200 Subject: [PATCH] :bug: Fix problem moving shapes into grid --- common/src/app/common/types/shape/layout.cljc | 13 ++++++++----- .../src/app/main/data/workspace/transforms.cljs | 5 ++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/common/src/app/common/types/shape/layout.cljc b/common/src/app/common/types/shape/layout.cljc index 73ae7c263..efccf250c 100644 --- a/common/src/app/common/types/shape/layout.cljc +++ b/common/src/app/common/types/shape/layout.cljc @@ -1294,11 +1294,14 @@ (->> (range start-index (inc to-index)) (map vector shape-ids) (reduce (fn [[parent cells] [shape-id idx]] - (let [[parent cells] (free-cell-push parent cells idx)] - [(update-in parent [:layout-grid-cells (get-in cells [idx :id])] - assoc :position :manual - :shapes [shape-id]) - cells])) + ;; If the shape to put in a cell is the same that is already in the cell we do nothing + (if (= shape-id (get-in parent [:layout-grid-cells (get-in cells [idx :id]) :shapes 0])) + [parent cells] + (let [[parent cells] (free-cell-push parent cells idx)] + [(update-in parent [:layout-grid-cells (get-in cells [idx :id])] + assoc :position :manual + :shapes [shape-id]) + cells]))) [parent cells]) (first))) parent))) diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 7f05c1bb0..7cea9cde9 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -585,7 +585,6 @@ :else [move-vector nil])] - (-> (dwm/create-modif-tree ids (ctm/move-modifiers move-vector)) (dwm/build-change-frame-modifiers objects selected target-frame drop-index cell-data) (dwm/set-modifiers false false {:snap-ignore-axis snap-ignore-axis})))))) @@ -608,11 +607,11 @@ (->> move-stream (rx/last) (rx/mapcat - (fn [[_ target-frame drop-index]] + (fn [[_ target-frame drop-index drop-cell]] (let [undo-id (js/Symbol)] (rx/of (dwu/start-undo-transaction undo-id) (dwm/apply-modifiers {:undo-transation? false}) - (move-shapes-to-frame ids target-frame drop-index nil) + (move-shapes-to-frame ids target-frame drop-index drop-cell) (finish-transform) (dwu/commit-undo-transaction undo-id))))))))))))))