diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 0b654fbb42..2109d034c2 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -1101,7 +1101,7 @@ "Add to the main shape `parent-main`, at `index`, a copy of `child-inst`, a child of the copy shape that pairs with it; `child-inst` then refers to the new main shape." - [changes {:keys [container main-container root-inst root-main libraries added synced-ids]} + [changes {:keys [container main-container root-inst root-main libraries added synced-ids inherited-turn]} parent-main child-inst index] (shape-log :info (:id child-inst) container :msg (str "ADD " (shape-label child-inst main-container))) @@ -1119,6 +1119,12 @@ (ctf/find-content-ref-shape nil container libraries child-inst :include-deleted? true :with-context? true)) + ;; copy shapes in the main's orientation, without the turn the copy inherits + in-main (fn [shape] + (-> (cond-> shape (some? inherited-turn) inherited-turn) + (reposition-shape (cond-> root-inst (some? inherited-turn) inherited-turn) + root-main))) + ;; The parent's inverse sync already pushed its geometry. Compare ;; against that frame, rather than its original container value. placement-container @@ -1126,12 +1132,12 @@ content-main (assoc-in [:objects (:id parent-main)] (-> (ctn/get-shape container (:parent-id child-inst)) - (reposition-shape root-inst root-main) + (in-main) (assoc :id (:id parent-main) :shape-ref (:shape-ref parent-main))))) update-new-shape (fn [new-shape original-shape] - (cond-> (reposition-shape new-shape root-inst root-main) + (cond-> (in-main new-shape) (and (= (:id original-shape) (:id child-inst)) (ctk/swapped? child-inst) (not swap-in-copy?)) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 8bda203af6..b8c64326c1 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -901,3 +901,10 @@ :when (not= :grid (:layout shape))] (t/is (empty? (:layout-grid-cells shape)) (:name shape)) (t/is (not (contains? (:touched shape) :layout-grid-cells)) (:name shape))))) + +(t/deftest generated-update-main-pushes-a-swap-in-its-mains-orientation + ;; a nested copy turned with the main that holds it swaps a child and + ;; pushes it into its own unturned main, which takes it unturned + (t/is (map? (cg/run {:world [2 1 {:variants true :text-styles true :library true :rich-variants true + :layout-copies true :text true}] + :ops [[:swap 6 0 0 0] [:transform 17 3 0 0] [:swap 9 0 0 0] [:edit 0 0 1 1] [:update-main 0]]}))))