mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 22:49:01 -05:00
🐛 Avoid setting touched in parent when swapping components
This commit is contained in:
parent
f152e30737
commit
d654a4faed
3 changed files with 19 additions and 16 deletions
|
@ -326,7 +326,9 @@
|
||||||
(some? index)
|
(some? index)
|
||||||
(assoc :index index)
|
(assoc :index index)
|
||||||
(:component-swap options)
|
(:component-swap options)
|
||||||
(assoc :component-swap true))
|
(assoc :component-swap true)
|
||||||
|
(:ignore-touched options)
|
||||||
|
(assoc :ignore-touched true))
|
||||||
|
|
||||||
mk-undo-change
|
mk-undo-change
|
||||||
(fn [undo-changes shape]
|
(fn [undo-changes shape]
|
||||||
|
@ -450,10 +452,11 @@
|
||||||
add-redo-change
|
add-redo-change
|
||||||
(fn [change-set id]
|
(fn [change-set id]
|
||||||
(conj change-set
|
(conj change-set
|
||||||
{:type :del-obj
|
(cond-> {:type :del-obj
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:ignore-touched ignore-touched
|
:id id}
|
||||||
:id id}))
|
ignore-touched
|
||||||
|
(assoc :ignore-touched true))))
|
||||||
|
|
||||||
add-undo-change-shape
|
add-undo-change-shape
|
||||||
(fn [change-set id]
|
(fn [change-set id]
|
||||||
|
|
|
@ -898,7 +898,8 @@
|
||||||
(pcb/update-shapes [(:id new-shape)] #(d/patch-object % keep-props-values))
|
(pcb/update-shapes [(:id new-shape)] #(d/patch-object % keep-props-values))
|
||||||
|
|
||||||
;; We need to set the same index as the original shape
|
;; We need to set the same index as the original shape
|
||||||
(pcb/change-parent (:parent-id shape) [new-shape] index {:component-swap true}))]
|
(pcb/change-parent (:parent-id shape) [new-shape] index {:component-swap true
|
||||||
|
:ignore-touched true}))]
|
||||||
|
|
||||||
;; First delete so we don't break the grid layout cells
|
;; First delete so we don't break the grid layout cells
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of (dch/commit-changes changes)
|
||||||
|
|
|
@ -142,17 +142,17 @@
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(update-shape-flags ids-to-hide {:hidden true}))
|
(update-shape-flags ids-to-hide {:hidden true}))
|
||||||
(real-delete-shapes file page objects ids-to-delete it components-v2)
|
(real-delete-shapes file page objects ids-to-delete it components-v2 (:component-swap options))
|
||||||
(rx/of (dwu/commit-undo-transaction undo-id))))))))
|
(rx/of (dwu/commit-undo-transaction undo-id))))))))
|
||||||
|
|
||||||
(defn- real-delete-shapes-changes
|
(defn- real-delete-shapes-changes
|
||||||
([file page objects ids it components-v2]
|
([file page objects ids it components-v2 ignore-touched]
|
||||||
(let [changes (-> (pcb/empty-changes it (:id page))
|
(let [changes (-> (pcb/empty-changes it (:id page))
|
||||||
(pcb/with-page page)
|
(pcb/with-page page)
|
||||||
(pcb/with-objects objects)
|
(pcb/with-objects objects)
|
||||||
(pcb/with-library-data file))]
|
(pcb/with-library-data file))]
|
||||||
(real-delete-shapes-changes changes file page objects ids it components-v2)))
|
(real-delete-shapes-changes changes file page objects ids it components-v2 ignore-touched)))
|
||||||
([changes file page objects ids _it components-v2]
|
([changes file page objects ids _it components-v2 ignore-touched]
|
||||||
(let [lookup (d/getf objects)
|
(let [lookup (d/getf objects)
|
||||||
groups-to-unmask
|
groups-to-unmask
|
||||||
(reduce (fn [group-ids id]
|
(reduce (fn [group-ids id]
|
||||||
|
@ -252,7 +252,7 @@
|
||||||
|
|
||||||
changes (-> changes
|
changes (-> changes
|
||||||
(pcb/remove-objects all-children {:ignore-touched true})
|
(pcb/remove-objects all-children {:ignore-touched true})
|
||||||
(pcb/remove-objects ids)
|
(pcb/remove-objects ids {:ignore-touched ignore-touched})
|
||||||
(pcb/remove-objects empty-parents)
|
(pcb/remove-objects empty-parents)
|
||||||
(pcb/resize-parents all-parents)
|
(pcb/resize-parents all-parents)
|
||||||
(pcb/update-shapes groups-to-unmask
|
(pcb/update-shapes groups-to-unmask
|
||||||
|
@ -274,13 +274,13 @@
|
||||||
|
|
||||||
|
|
||||||
(defn delete-shapes-changes
|
(defn delete-shapes-changes
|
||||||
[changes file page objects ids it components-v2]
|
[changes file page objects ids it components-v2 ignore-touched]
|
||||||
(let [[changes _all-parents] (real-delete-shapes-changes changes file page objects ids it components-v2)]
|
(let [[changes _all-parents] (real-delete-shapes-changes changes file page objects ids it components-v2 ignore-touched)]
|
||||||
changes))
|
changes))
|
||||||
|
|
||||||
(defn- real-delete-shapes
|
(defn- real-delete-shapes
|
||||||
[file page objects ids it components-v2]
|
[file page objects ids it components-v2 ignore-touched]
|
||||||
(let [[changes all-parents] (real-delete-shapes-changes file page objects ids it components-v2)
|
(let [[changes all-parents] (real-delete-shapes-changes file page objects ids it components-v2 ignore-touched)
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dc/detach-comment-thread ids)
|
(dc/detach-comment-thread ids)
|
||||||
|
@ -288,7 +288,6 @@
|
||||||
(ptk/data-event :layout/update all-parents)
|
(ptk/data-event :layout/update all-parents)
|
||||||
(dwu/commit-undo-transaction undo-id))))
|
(dwu/commit-undo-transaction undo-id))))
|
||||||
|
|
||||||
|
|
||||||
(defn create-and-add-shape
|
(defn create-and-add-shape
|
||||||
[type frame-x frame-y {:keys [width height] :as attrs}]
|
[type frame-x frame-y {:keys [width height] :as attrs}]
|
||||||
(ptk/reify ::create-and-add-shape
|
(ptk/reify ::create-and-add-shape
|
||||||
|
|
Loading…
Add table
Reference in a new issue