diff --git a/CHANGES.md b/CHANGES.md index c20143fa1..84515126b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 372b0ce1b..6b714fb46 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -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))))))