diff --git a/CHANGES.md b/CHANGES.md index b9a6b6b527..c4f89d6793 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ - Fix text-decoration line-through that displays a wrong property value [Taiga #11145](https://tree.taiga.io/project/penpot/issue/11145) - Fix display error message on register form [Taiga #11444](https://tree.taiga.io/project/penpot/issue/11444) - Fix toggle focus mode did not restore viewport and selection upon exit [GitHub #6280](https://github.com/penpot/penpot/issues/6820) +- Fix problem when creating a layout from an existing layout [Taiga #11554](https://tree.taiga.io/project/penpot/issue/11554) ## 2.8.0 diff --git a/frontend/src/app/main/data/workspace/shape_layout.cljs b/frontend/src/app/main/data/workspace/shape_layout.cljs index a58c81c332..9880d68293 100644 --- a/frontend/src/app/main/data/workspace/shape_layout.cljs +++ b/frontend/src/app/main/data/workspace/shape_layout.cljs @@ -181,6 +181,8 @@ is-component? (and single? has-component?) has-variant? (some ctc/is-variant? selected-shapes) + has-layout? (and single? (ctl/any-layout? (first selected-shapes))) + new-shape-id (uuid/next) undo-id (js/Symbol)] @@ -188,7 +190,8 @@ (rx/empty) (rx/concat (rx/of (dwu/start-undo-transaction undo-id)) - (if (and is-group? (not is-component?) (not is-mask?)) + (cond + (and is-group? (not is-component?) (not is-mask?)) ;; Create layout from a group: ;; When creating a layout from a group we remove the group and create the layout with its children (let [parent-id (:parent-id (first selected-shapes)) @@ -206,7 +209,14 @@ (ptk/data-event :layout/update {:ids [new-shape-id]}) (dwu/commit-undo-transaction undo-id))) + has-layout? + (rx/of + (create-layout-from-id (first selected) type) + (ptk/data-event :layout/update {:ids selected}) + (dwu/commit-undo-transaction undo-id)) + ;; Create Layout from selection + :else (rx/of (dwsh/create-artboard-from-selection new-shape-id) (cl/remove-all-fills [new-shape-id] {:color clr/black :opacity 1})