0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

🐛 Fix duplicate a component copy missing shape-ref

This commit is contained in:
Pablo Alba 2023-07-14 08:47:34 +02:00 committed by Andrés Moya
parent 1106ebc377
commit 9b9f2c39b9

View file

@ -397,9 +397,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)))
(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))
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id frame-id parent-id]
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id frame-id parent-id duplicating-component?]
(cond
(nil? obj)
changes
@ -413,8 +413,9 @@
parent-id (or parent-id frame-id)
name (:name obj)
is-component-root? (:saved-component-root? obj)
is-component-main? (:main-instance? obj)
is-component-root? (or (:saved-component-root? obj) (ctk/instance-root? obj))
duplicating-component? (or duplicating-component? is-component-root?)
is-component-main? (ctk/main-instance? obj)
regenerate-component
(fn [changes shape]
(let [components-v2 (dm/get-in library-data [:options :components-v2])
@ -428,12 +429,15 @@
:frame-id frame-id)
(dissoc :shapes
:main-instance?
:shape-ref
:use-for-thumbnail?)
(gsh/move delta)
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))
changes (-> (pcb/add-object changes new-obj)
new-obj (cond-> new-obj
(not duplicating-component?)
(dissoc :shape-ref))
changes (-> (pcb/add-object changes new-obj {:ignore-touched duplicating-component?})
(pcb/amend-last-change #(assoc % :old-id (:id obj))))
changes (cond-> changes
@ -454,7 +458,8 @@
it
file-id
(if frame? new-id frame-id)
new-id))
new-id
duplicating-component?))
changes
(map (d/getf objects) (:shapes obj)))))))