0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-23 07:16:07 -05:00

🐛 Fix problem with grid layout duplicate positioning (#5877)

This commit is contained in:
Alonso Torres 2025-02-18 10:17:42 +01:00 committed by GitHub
parent 3412a0a18a
commit 0900b7a572
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View file

@ -12,7 +12,6 @@
[app.common.files.helpers :as cfh] [app.common.files.helpers :as cfh]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.geom.shapes.grid-layout :as gslg]
[app.common.logging :as log] [app.common.logging :as log]
[app.common.logic.shapes :as cls] [app.common.logic.shapes :as cls]
[app.common.spec :as us] [app.common.spec :as us]
@ -226,18 +225,19 @@
changes changes
(if (ctl/grid-layout? objects (:parent-id first-shape)) (if (ctl/grid-layout? objects (:parent-id first-shape))
(let [target-cell (-> position meta :cell) (let [target-cell (-> position meta :cell)
[row column] [row column]
(if (some? target-cell) (when (some? target-cell)
[(:row target-cell) (:column target-cell)] [(:row target-cell) (:column target-cell)])]
(gslg/get-drop-cell (:parent-id first-shape) objects position))]
(-> changes (-> changes
(pcb/update-shapes (pcb/update-shapes
[(:parent-id first-shape)] [(:parent-id first-shape)]
(fn [shape objects] (fn [shape objects]
(-> shape (-> shape
(ctl/assign-cells objects) (ctl/assign-cells objects)
(ctl/push-into-cell [(:id first-shape)] row column) (cond-> (and (some? row) (some? column))
(ctl/assign-cells objects))) (-> (ctl/push-into-cell [(:id first-shape)] row column)
(ctl/assign-cells objects)))))
{:with-objects? true}) {:with-objects? true})
(pcb/reorder-grid-children [(:parent-id first-shape)]))) (pcb/reorder-grid-children [(:parent-id first-shape)])))
changes) changes)

View file

@ -1307,9 +1307,9 @@
"Push the shapes into the row/column cell and moves the rest" "Push the shapes into the row/column cell and moves the rest"
[parent shape-ids row column] [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)] [start-index start-cell] (seek-indexed-cell cells row column)]
(if (some? start-cell) (if (some? start-cell)
(let [;; start-index => to-index is the range where the shapes inserted will be added (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)))] to-index (min (+ start-index (count shape-ids)) (dec (count cells)))]