🐛 Fix allow moving a main component into another

This commit is contained in:
Pablo Alba 2025-04-16 17:20:52 +02:00 committed by Pablo Alba
parent 93c81ea49c
commit 70a23a14c4
2 changed files with 13 additions and 3 deletions

View file

@ -8,6 +8,7 @@
- Fix scroll on token themes modal [Taiga #10745](https://tree.taiga.io/project/penpot/issue/10745)
- Fix unexpected exception on path editor on merge segments when undo stack is empty
- Fix pricing CTA to be under a config flag [Taiga #10808](https://tree.taiga.io/project/penpot/issue/10808)
- Fix allow moving a main component into another [Taiga #10818](https://tree.taiga.io/project/penpot/issue/10818)
## 2.6.1

View file

@ -543,14 +543,23 @@
;; We can always move the children to the parent they already have.
;; But if we are pasting, those are new items, so it is considered a change
no-changes?
(and (->> children (every? #(= parent-id (:parent-id %))))
(and (every? #(= parent-id (:parent-id %)) children)
(not pasting?))
all-main?
(->> children (every? #(ctk/main-instance? %)))]
(every? ctk/main-instance? children)
any-main-descendant
(some
(fn [shape]
(some ctk/main-instance? (cfh/get-children-with-self objects (:id shape))))
children)]
(if (or no-changes?
(and (not (invalid-structure-for-component? objects parent children pasting? libraries))
;; If we are moving into a variant-container, all the items should be main
(or all-main? (not (ctk/is-variant-container? parent)))))
(or all-main? (not (ctk/is-variant-container? parent)))
;; If we are moving into a main component, no descendant can be main
(or (nil? any-main-descendant) (not (ctk/main-instance? parent)))))
[parent-id (get-frame parent-id)]
(recur (:parent-id parent) objects children pasting? libraries))))))