0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-22 23:06:08 -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.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)

View file

@ -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)))]