0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 17:00:36 -05:00

Merge pull request #3613 from penpot/hiru-fix-parent-touched

🐛 Fix parent touched detecion when duplicating or copy&paste
This commit is contained in:
Pablo Alba 2023-09-11 13:50:38 +02:00 committed by GitHub
commit 3228d0a95f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -412,9 +412,9 @@
(defn- prepare-duplicate-shape-change
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id]
(prepare-duplicate-shape-change changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id (:frame-id obj) (:parent-id obj) false))
(prepare-duplicate-shape-change changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id (:frame-id obj) (:parent-id obj) false false))
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id frame-id parent-id duplicating-component?]
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id frame-id parent-id duplicating-component? child?]
(cond
(nil? obj)
changes
@ -466,7 +466,8 @@
(not duplicating-component?)
(dissoc :shape-ref))
changes (-> (pcb/add-object changes new-obj {:ignore-touched duplicating-component?})
; We want the first added object to touch it's parent, but not subsequent children
changes (-> (pcb/add-object changes new-obj {:ignore-touched (and duplicating-component? child?)})
(pcb/amend-last-change #(assoc % :old-id (:id obj))))
changes (cond-> changes
@ -488,7 +489,8 @@
file-id
(if frame? new-id frame-id)
new-id
duplicating-component?))
duplicating-component?
true))
changes
(map (d/getf objects) (:shapes obj)))))))