From 0900b7a5729efd74f297392bff82761ea19382e2 Mon Sep 17 00:00:00 2001 From: Alonso Torres Date: Tue, 18 Feb 2025 10:17:42 +0100 Subject: [PATCH] :bug: Fix problem with grid layout duplicate positioning (#5877) --- common/src/app/common/logic/libraries.cljc | 12 ++++++------ common/src/app/common/types/shape/layout.cljc | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index adfea7774..be9c482b5 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -12,7 +12,6 @@ [app.common.files.helpers :as cfh] [app.common.geom.point :as gpt] [app.common.geom.shapes :as gsh] - [app.common.geom.shapes.grid-layout :as gslg] [app.common.logging :as log] [app.common.logic.shapes :as cls] [app.common.spec :as us] @@ -226,18 +225,19 @@ changes (if (ctl/grid-layout? objects (:parent-id first-shape)) (let [target-cell (-> position meta :cell) + [row column] - (if (some? target-cell) - [(:row target-cell) (:column target-cell)] - (gslg/get-drop-cell (:parent-id first-shape) objects position))] + (when (some? target-cell) + [(:row target-cell) (:column target-cell)])] (-> changes (pcb/update-shapes [(:parent-id first-shape)] (fn [shape objects] (-> shape (ctl/assign-cells objects) - (ctl/push-into-cell [(:id first-shape)] row column) - (ctl/assign-cells objects))) + (cond-> (and (some? row) (some? column)) + (-> (ctl/push-into-cell [(:id first-shape)] row column) + (ctl/assign-cells objects))))) {:with-objects? true}) (pcb/reorder-grid-children [(:parent-id first-shape)]))) changes) diff --git a/common/src/app/common/types/shape/layout.cljc b/common/src/app/common/types/shape/layout.cljc index 84a8f0000..423e2a4d2 100644 --- a/common/src/app/common/types/shape/layout.cljc +++ b/common/src/app/common/types/shape/layout.cljc @@ -1307,9 +1307,9 @@ "Push the shapes into the row/column cell and moves the rest" [parent shape-ids row column] - (let [cells (vec (get-cells parent {:sort? true})) + (let [parent (-> parent (free-cell-shapes shape-ids)) + cells (vec (get-cells parent {:sort? true})) [start-index start-cell] (seek-indexed-cell cells row column)] - (if (some? start-cell) (let [;; start-index => to-index is the range where the shapes inserted will be added to-index (min (+ start-index (count shape-ids)) (dec (count cells)))]