diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 1bdd0057c0..9537161e51 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -954,7 +954,8 @@ (defn- rehead-pushed-swap "A pushed swap becomes a plain nested copy. Its old position's - orientation becomes authored when it differs from its own main." + orientation and constraints become authored when they differ from its + own main." [shape main container] (let [shape (-> shape (assoc :shape-ref (:id main)) @@ -965,7 +966,10 @@ expected (get-in main-container [:objects (:id main)])] (cond-> shape (and expected (orient-like shape expected (gsh/shape->center shape))) - (update :touched ctk/set-touched-group :geometry-group)))) + (update :touched ctk/set-touched-group :geometry-group) + + (and main (some #(not= (get shape %) (get main %)) [:constraints-h :constraints-v :fixed-scroll])) + (update :touched ctk/set-touched-group :constraints-group)))) (defn- author-pushed-content "Taking a new content reference makes the pushed differences authored. diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 1c35405c4d..e30767f8b5 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -683,6 +683,19 @@ (t/is (mth/close? 0 (rotation :sync-random-0-outer-0) 0.01)) (t/is (mth/close? 45 (rotation :sync-random-0-innercopy-1) 0.01)))) +(t/deftest a-pushed-swap-authors-the-constraints-of-its-old-position + (let [program {:world [2 0 {:variants true :text-styles true :layout nil :layout-item-margins false + :library true :rich-variants true :layout-children false + :layout-copies true :text true}] + :ops [[:style 12 7 7 0] [:nest 0 0 0 0] [:swap 8 0 0 0] [:edit 0 0 1 1] [:update-main 0]]} + situation (:situation (cg/run program)) + outer (tm/shape-by-id situation (thi/id :sync-variant-outer-0)) + pushed (tm/shape-by-id situation (first (:shapes outer)))] + ;; The old position authored fixed scroll; the new nested copy keeps it + ;; against its own main, which does not scroll. + (t/is (true? (:fixed-scroll pushed))) + (t/is (contains? (:touched pushed) :constraints-group)))) + (t/deftest detached-swapped-head-follows-its-own-component-without-position-overrides (t/is (map? (cg/run {:world [2 1 {:library true :variants true}] :ops [[:edit 0 0 1 2] [:update-main 0] [:library-sync]