0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-22 14:39:45 -05:00

🐛 Fix issue when undo after changing the artboard of a shape

This commit is contained in:
alonso.torres 2021-03-09 12:49:31 +01:00
parent 47e0c2c75b
commit d263dd52e9
4 changed files with 17 additions and 5 deletions

View file

@ -19,6 +19,7 @@
- Fix problem with mask and flip [#715](https://github.com/penpot/penpot/issues/715)
- Fix problem with rotated blur [Taiga #1370](https://tree.taiga.io/project/penpot/issue/1370)
- Disables buttons in view mode for users without permissions [Taiga #1328](https://tree.taiga.io/project/penpot/issue/1328)
- Fix issue when undo after changing the artboard of a shape [Taiga #1304](https://tree.taiga.io/project/penpot/issue/1304)
### :heart: Community contributions by (Thank you!)

View file

@ -62,6 +62,7 @@
(d/export helpers/touched-group?)
(d/export helpers/get-base-shape)
(d/export helpers/is-parent?)
(d/export helpers/get-index-in-parent)
;; Process changes
(d/export changes/process-changes)

View file

@ -401,3 +401,12 @@
(recur (get objects (first pending))
(conj done (:id current))
(concat (rest pending) (:shapes current))))))
(defn get-index-in-parent
"Retrieves the index in the parent"
[objects shape-id]
(let [shape (get objects shape-id)
parent (get objects (:parent-id shape))
[parent-idx _] (d/seek (fn [[idx child-id]] (= child-id shape-id))
(d/enumerate (:shapes parent)))]
parent-idx))

View file

@ -249,14 +249,15 @@
:parent-id frame-id
:shapes (mapv :id moving-shapes)}]
moving-shapes-by-frame-id (group-by :frame-id moving-shapes)
uch (->> moving-shapes-by-frame-id
(mapv (fn [[frame-id shapes]]
uch (->> moving-shapes
(reverse)
(mapv (fn [shape]
{:type :mov-objects
:page-id page-id
:parent-id frame-id
:shapes (mapv :id shapes)})))]
:parent-id (:parent-id shape)
:index (cp/get-index-in-parent objects (:id shape))
:shapes [(:id shape)]})))]
(when-not (empty? rch)
(rx/of dwc/pop-undo-into-transaction