mirror of
https://github.com/penpot/penpot.git
synced 2025-07-27 22:07:19 +02:00
🐛 Fix undo ungroup (shift+g) scrambles positions
This commit is contained in:
parent
acf51ea744
commit
a555028ee2
3 changed files with 17 additions and 8 deletions
|
@ -42,6 +42,7 @@
|
||||||
- Fix ghost shapes after sync groups in components [Taiga #4649](https://tree.taiga.io/project/penpot/issue/4649)
|
- 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 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 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
|
## 1.16.2-beta
|
||||||
|
|
||||||
|
|
|
@ -378,14 +378,16 @@
|
||||||
|
|
||||||
add-undo-change-parent
|
add-undo-change-parent
|
||||||
(fn [change-set id]
|
(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
|
(d/preconj
|
||||||
change-set
|
change-set
|
||||||
{:type :mov-objects
|
{:type :mov-objects
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:parent-id (:parent-id shape)
|
:parent-id (:parent-id shape)
|
||||||
:shapes [id]
|
:shapes [id]
|
||||||
:index (cph/get-position-on-parent objects id)
|
:after-shape prev-sibling
|
||||||
|
:index 0
|
||||||
:ignore-touched true})))]
|
:ignore-touched true})))]
|
||||||
|
|
||||||
(-> changes
|
(-> changes
|
||||||
|
|
|
@ -23,9 +23,8 @@
|
||||||
[objects selected]
|
[objects selected]
|
||||||
(->> selected
|
(->> selected
|
||||||
(cph/order-by-indexed-shapes objects)
|
(cph/order-by-indexed-shapes objects)
|
||||||
(map #(get objects %))
|
reverse
|
||||||
(map #(assoc % ::index (cph/get-position-on-parent objects (:id %))))
|
(map #(get objects %))))
|
||||||
(sort-by ::index)))
|
|
||||||
|
|
||||||
(defn- get-empty-groups-after-group-creation
|
(defn- get-empty-groups-after-group-creation
|
||||||
"An auxiliary function that finds and returns a set of ids that
|
"An auxiliary function that finds and returns a set of ids that
|
||||||
|
@ -77,7 +76,11 @@
|
||||||
(ctst/generate-unique-name base-name)))
|
(ctst/generate-unique-name base-name)))
|
||||||
|
|
||||||
selrect (gsh/selection-rect shapes)
|
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)
|
group (-> (cts/make-minimal-group frame-id selrect gname)
|
||||||
(cts/setup-shape selrect)
|
(cts/setup-shape selrect)
|
||||||
(assoc :shapes (mapv :id shapes)
|
(assoc :shapes (mapv :id shapes)
|
||||||
|
@ -114,7 +117,8 @@
|
||||||
(->> (:shapes parent)
|
(->> (:shapes parent)
|
||||||
(map-indexed vector)
|
(map-indexed vector)
|
||||||
(filter #(#{(:id group)} (second %)))
|
(filter #(#{(:id group)} (second %)))
|
||||||
(ffirst))
|
(ffirst)
|
||||||
|
inc)
|
||||||
|
|
||||||
;; Shapes that are in a component (including root) must be detached,
|
;; Shapes that are in a component (including root) must be detached,
|
||||||
;; because cannot be easyly synchronized back to the main component.
|
;; because cannot be easyly synchronized back to the main component.
|
||||||
|
@ -133,7 +137,9 @@
|
||||||
(cph/order-by-indexed-shapes objects)
|
(cph/order-by-indexed-shapes objects)
|
||||||
(mapv #(get objects %)))
|
(mapv #(get objects %)))
|
||||||
parent-id (cph/get-parent-id objects (:id frame))
|
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/empty-changes it page-id)
|
||||||
(pcb/with-objects objects)
|
(pcb/with-objects objects)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue