mirror of
https://github.com/penpot/penpot.git
synced 2025-05-22 04:46:10 +02:00
🐛 Fix erroneous touched state when delete a copy and then undo
This commit is contained in:
parent
0b316d6828
commit
8c3f90fe36
2 changed files with 47 additions and 45 deletions
|
@ -359,54 +359,56 @@
|
||||||
(apply-changes-local)))))
|
(apply-changes-local)))))
|
||||||
|
|
||||||
(defn remove-objects
|
(defn remove-objects
|
||||||
[changes ids]
|
([changes ids] (remove-objects changes ids nil))
|
||||||
(assert-page-id changes)
|
([changes ids {:keys [ignore-touched] :or {ignore-touched false}}]
|
||||||
(assert-objects changes)
|
(assert-page-id changes)
|
||||||
(let [page-id (::page-id (meta changes))
|
(assert-objects changes)
|
||||||
objects (lookup-objects changes)
|
(let [page-id (::page-id (meta changes))
|
||||||
|
objects (lookup-objects changes)
|
||||||
|
|
||||||
add-redo-change
|
add-redo-change
|
||||||
(fn [change-set id]
|
(fn [change-set id]
|
||||||
(conj change-set
|
(conj change-set
|
||||||
{:type :del-obj
|
{:type :del-obj
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:id id}))
|
:ignore-touched ignore-touched
|
||||||
|
:id id}))
|
||||||
|
|
||||||
add-undo-change-shape
|
add-undo-change-shape
|
||||||
(fn [change-set id]
|
(fn [change-set id]
|
||||||
(let [shape (get objects id)]
|
(let [shape (get objects id)]
|
||||||
(d/preconj
|
(d/preconj
|
||||||
change-set
|
change-set
|
||||||
{:type :add-obj
|
{:type :add-obj
|
||||||
:id id
|
:id id
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:parent-id (:frame-id shape)
|
:parent-id (:frame-id shape)
|
||||||
:frame-id (:frame-id shape)
|
:frame-id (:frame-id shape)
|
||||||
:index (cph/get-position-on-parent objects id)
|
:index (cph/get-position-on-parent objects id)
|
||||||
:obj (cond-> shape
|
:obj (cond-> shape
|
||||||
(contains? shape :shapes)
|
(contains? shape :shapes)
|
||||||
(assoc :shapes []))})))
|
(assoc :shapes []))})))
|
||||||
|
|
||||||
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))]
|
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]
|
||||||
:after-shape prev-sibling
|
:after-shape prev-sibling
|
||||||
:index 0
|
:index 0
|
||||||
:ignore-touched true})))]
|
:ignore-touched true})))]
|
||||||
|
|
||||||
(-> changes
|
(-> changes
|
||||||
(update :redo-changes #(reduce add-redo-change % ids))
|
(update :redo-changes #(reduce add-redo-change % ids))
|
||||||
(update :undo-changes #(as-> % $
|
(update :undo-changes #(as-> % $
|
||||||
(reduce add-undo-change-parent $ ids)
|
(reduce add-undo-change-parent $ ids)
|
||||||
(reduce add-undo-change-shape $ ids)))
|
(reduce add-undo-change-shape $ ids)))
|
||||||
(apply-changes-local))))
|
(apply-changes-local)))))
|
||||||
|
|
||||||
(defn resize-parents
|
(defn resize-parents
|
||||||
[changes ids]
|
[changes ids]
|
||||||
|
|
|
@ -314,7 +314,7 @@
|
||||||
components-to-delete)
|
components-to-delete)
|
||||||
|
|
||||||
changes (-> changes
|
changes (-> changes
|
||||||
(pcb/remove-objects all-children)
|
(pcb/remove-objects all-children {:ignore-touched true})
|
||||||
(pcb/remove-objects ids)
|
(pcb/remove-objects ids)
|
||||||
(pcb/remove-objects empty-parents)
|
(pcb/remove-objects empty-parents)
|
||||||
(pcb/resize-parents all-parents)
|
(pcb/resize-parents all-parents)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue