mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 20:46:11 +02:00
🐛 Fix keep index for swap components
This commit is contained in:
parent
c0a2550485
commit
c4ce83bb07
1 changed files with 5 additions and 4 deletions
|
@ -827,7 +827,7 @@
|
||||||
0)))))
|
0)))))
|
||||||
|
|
||||||
(defn- add-component-for-swap
|
(defn- add-component-for-swap
|
||||||
[shape file-id id-new-component target-cell]
|
[shape file-id id-new-component index target-cell]
|
||||||
(dm/assert! (uuid? id-new-component))
|
(dm/assert! (uuid? id-new-component))
|
||||||
(dm/assert! (uuid? file-id))
|
(dm/assert! (uuid? file-id))
|
||||||
(ptk/reify ::add-component-for-swap
|
(ptk/reify ::add-component-for-swap
|
||||||
|
@ -837,7 +837,6 @@
|
||||||
libraries (wsh/get-libraries state)
|
libraries (wsh/get-libraries state)
|
||||||
|
|
||||||
objects (:objects page)
|
objects (:objects page)
|
||||||
index (find-shape-index objects (:parent-id shape) (:id shape))
|
|
||||||
position (gpt/point (:x shape) (:y shape))
|
position (gpt/point (:x shape) (:y shape))
|
||||||
changes (-> (pcb/empty-changes it (:id page))
|
changes (-> (pcb/empty-changes it (:id page))
|
||||||
(pcb/with-objects objects))
|
(pcb/with-objects objects))
|
||||||
|
@ -877,9 +876,11 @@
|
||||||
|
|
||||||
;; If the target parent is a grid layout we need to pass the target cell
|
;; If the target parent is a grid layout we need to pass the target cell
|
||||||
target-cell (when (ctl/grid-layout? parent)
|
target-cell (when (ctl/grid-layout? parent)
|
||||||
(ctl/get-cell-by-shape-id parent (:id shape)))]
|
(ctl/get-cell-by-shape-id parent (:id shape)))
|
||||||
|
|
||||||
|
index (find-shape-index objects (:parent-id shape) (:id shape))]
|
||||||
(rx/of (dwsh/delete-shapes nil (d/ordered-set (:id shape)) {:component-swap true})
|
(rx/of (dwsh/delete-shapes nil (d/ordered-set (:id shape)) {:component-swap true})
|
||||||
(add-component-for-swap shape file-id id-new-component target-cell)
|
(add-component-for-swap shape file-id id-new-component index target-cell)
|
||||||
(ptk/data-event :layout/update [(:parent-id shape)]))))))
|
(ptk/data-event :layout/update [(:parent-id shape)]))))))
|
||||||
|
|
||||||
(defn component-multi-swap
|
(defn component-multi-swap
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue