0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 02:28:18 -05:00

Merge pull request #2768 from penpot/palba-more-undo-tuning

🐛 Fix undo ungroup (shift+g) scrambles positions
This commit is contained in:
Alejandro 2023-01-12 13:31:59 +01:00 committed by GitHub
commit 44102050ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

View file

@ -42,6 +42,7 @@
- Fix ghost shapes after sync groups in components [Taiga #4649](https://tree.taiga.io/project/penpot/issue/4649)
- Fix layer orders messed up on move, group, reparent and undo [Github #2672](https://github.com/penpot/penpot/issues/2672)
- Fix max height in library dialog [Github #2335](https://github.com/penpot/penpot/issues/2335)
- Fix undo ungroup (shift+g) scrambles positions [Taiga #4674](https://tree.taiga.io/project/penpot/issue/4674)
## 1.16.2-beta

View file

@ -378,14 +378,16 @@
add-undo-change-parent
(fn [change-set id]
(let [shape (get objects id)]
(let [shape (get objects id)
prev-sibling (cph/get-prev-sibling objects (:id shape))]
(d/preconj
change-set
{:type :mov-objects
:page-id page-id
:parent-id (:parent-id shape)
:shapes [id]
:index (cph/get-position-on-parent objects id)
:after-shape prev-sibling
:index 0
:ignore-touched true})))]
(-> changes

View file

@ -24,9 +24,8 @@
[objects selected]
(->> selected
(cph/order-by-indexed-shapes objects)
(map #(get objects %))
(map #(assoc % ::index (cph/get-position-on-parent objects (:id %))))
(sort-by ::index)))
reverse
(map #(get objects %))))
(defn- get-empty-groups-after-group-creation
"An auxiliary function that finds and returns a set of ids that
@ -78,7 +77,11 @@
(ctst/generate-unique-name base-name)))
selrect (gsh/selection-rect shapes)
group-idx (inc (::index (last shapes)))
group-idx (->> shapes
last
:id
(cph/get-position-on-parent objects)
inc)
group (-> (cts/make-minimal-group frame-id selrect gname)
(cts/setup-shape selrect)
(assoc :shapes (mapv :id shapes)
@ -115,7 +118,8 @@
(->> (:shapes parent)
(map-indexed vector)
(filter #(#{(:id group)} (second %)))
(ffirst))
(ffirst)
inc)
;; Shapes that are in a component (including root) must be detached,
;; because cannot be easyly synchronized back to the main component.
@ -134,7 +138,9 @@
(cph/order-by-indexed-shapes objects)
(mapv #(get objects %)))
parent-id (cph/get-parent-id objects (:id frame))
idx-in-parent (cph/get-position-on-parent objects (:id frame))]
idx-in-parent (->> (:id frame)
(cph/get-position-on-parent objects)
inc)]
(-> (pcb/empty-changes it page-id)
(pcb/with-objects objects)