mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 18:31:38 +02:00
🐛 Fix problem with undo operation and children order
This commit is contained in:
parent
899dc5b680
commit
7efc1a0366
3 changed files with 12 additions and 8 deletions
|
@ -99,7 +99,8 @@
|
||||||
|
|
||||||
;; Implemented with transient for performance
|
;; Implemented with transient for performance
|
||||||
(defn get-children
|
(defn get-children
|
||||||
"Retrieve all children ids recursively for a given object"
|
"Retrieve all children ids recursively for a given object. The
|
||||||
|
children's order will be breadth first."
|
||||||
[id objects]
|
[id objects]
|
||||||
|
|
||||||
(loop [result (transient [])
|
(loop [result (transient [])
|
||||||
|
|
|
@ -350,6 +350,8 @@
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
|
|
||||||
|
ids (cp/clean-loops objects ids)
|
||||||
|
|
||||||
groups-to-unmask
|
groups-to-unmask
|
||||||
(reduce (fn [group-ids id]
|
(reduce (fn [group-ids id]
|
||||||
;; When the shape to delete is the mask of a masked group,
|
;; When the shape to delete is the mask of a masked group,
|
||||||
|
@ -387,10 +389,12 @@
|
||||||
ids)
|
ids)
|
||||||
|
|
||||||
all-children
|
all-children
|
||||||
(reduce (fn [res id]
|
(->> ids
|
||||||
(into res (cp/get-children id objects)))
|
(reduce (fn [res id]
|
||||||
(d/ordered-set)
|
(into res (cp/get-children id objects)))
|
||||||
ids)
|
[])
|
||||||
|
(reverse)
|
||||||
|
(into (d/ordered-set)))
|
||||||
|
|
||||||
empty-parents
|
empty-parents
|
||||||
(into (d/ordered-set) empty-parents-xform all-parents)
|
(into (d/ordered-set) empty-parents-xform all-parents)
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
(ns app.main.data.workspace.undo
|
(ns app.main.data.workspace.undo
|
||||||
(:require
|
(:require
|
||||||
[app.common.pages :as cp]
|
|
||||||
[app.common.pages.spec :as spec]
|
[app.common.pages.spec :as spec]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
|
@ -31,13 +30,13 @@
|
||||||
(subvec undo (- cnt MAX-UNDO-SIZE))
|
(subvec undo (- cnt MAX-UNDO-SIZE))
|
||||||
undo)))
|
undo)))
|
||||||
|
|
||||||
|
;; TODO: Review the necessity of this method
|
||||||
(defn materialize-undo
|
(defn materialize-undo
|
||||||
[changes index]
|
[_changes index]
|
||||||
(ptk/reify ::materialize-undo
|
(ptk/reify ::materialize-undo
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(update :workspace-data cp/process-changes changes)
|
|
||||||
(assoc-in [:workspace-undo :index] index)))))
|
(assoc-in [:workspace-undo :index] index)))))
|
||||||
|
|
||||||
(defn- add-undo-entry
|
(defn- add-undo-entry
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue