mirror of
https://github.com/penpot/penpot.git
synced 2025-02-02 04:19:08 -05:00
🐛 Fix validation error detaching copy inside main
This commit is contained in:
parent
fd43091d3a
commit
cc9e517720
1 changed files with 11 additions and 6 deletions
|
@ -201,18 +201,23 @@
|
||||||
"Generate changes to remove the links between a shape and all its children
|
"Generate changes to remove the links between a shape and all its children
|
||||||
with a component."
|
with a component."
|
||||||
[changes container shape-id]
|
[changes container shape-id]
|
||||||
|
(let [shape (ctn/get-shape container shape-id)]
|
||||||
(log/debug :msg "Detach instance" :shape-id shape-id :container (:id container))
|
(log/debug :msg "Detach instance" :shape-id shape-id :container (:id container))
|
||||||
(generate-detach-recursive changes container shape-id true))
|
(generate-detach-recursive changes container shape-id true (true? (:component-root shape)))))
|
||||||
|
|
||||||
(defn- generate-detach-recursive
|
(defn- generate-detach-recursive
|
||||||
[changes container shape-id first]
|
[changes container shape-id first component-root?]
|
||||||
(let [shape (ctn/get-shape container shape-id)]
|
(let [shape (ctn/get-shape container shape-id)]
|
||||||
(if (and (ctk/instance-head? shape) (not first))
|
(if (and (ctk/instance-head? shape) (not first))
|
||||||
;; Subinstances are not detached, but converted in top instances
|
;; Subinstances are not detached
|
||||||
|
(if component-root?
|
||||||
|
;; if the original shape was component-root, the subinstances are converted in top instances
|
||||||
(pcb/update-shapes changes [(:id shape)] #(assoc % :component-root true))
|
(pcb/update-shapes changes [(:id shape)] #(assoc % :component-root true))
|
||||||
|
changes)
|
||||||
|
|
||||||
;; Otherwise, detach the shape and all children
|
;; Otherwise, detach the shape and all children
|
||||||
(let [children-ids (:shapes shape)]
|
(let [children-ids (:shapes shape)]
|
||||||
(reduce #(generate-detach-recursive %1 container %2 false)
|
(reduce #(generate-detach-recursive %1 container %2 false component-root?)
|
||||||
(pcb/update-shapes changes [(:id shape)] ctk/detach-shape)
|
(pcb/update-shapes changes [(:id shape)] ctk/detach-shape)
|
||||||
children-ids)))))
|
children-ids)))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue