diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 221866d576..f0b7a575d6 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -2157,11 +2157,16 @@ (pcb/with-objects objects)) file (assoc libraries (:id file) file) container (:id head) false) - placed (pcb/get-objects proposal)] + placed (pcb/get-objects proposal) + ;; the sync places the parent before its layout does; follow the parent where it is + offset (if-let [proposed (get placed (:id parent))] + (gpt/subtract (first (:points parent)) (first (:points proposed))) + (gpt/point 0 0))] (pcb/update-shapes changes (cfh/get-children-ids-with-self objects shape-id) (fn [shape] - (let [expected (get placed (:id shape)) + (let [expected (cond-> (get placed (:id shape)) + (not (gpt/close? offset (gpt/point 0 0))) (gsh/move offset)) attrs (cond-> placement-geometry-attrs (= :path (:type shape)) (conj :content))] (if (= (:type shape) (:type expected)) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 83677c227f..7ddbe1763d 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1084,3 +1084,12 @@ (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff false :rich-variants true :layout-copies true :text true}] :ops [[:nest 6 0 0 0] [:style 8 1 1] [:switch 4 0 0 0]]})))) + +(t/deftest generated-reset-in-a-reversed-flex-copy-stays-with-its-parent + ;; a copy inside a nested copy that a resized, reversed flex copy places + ;; elsewhere than its main is reset beside that parent + (t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :layout :flex :library true :rich-variants true + :layout-copies true :text true}] + :ops [[:edit 18 0 0 0] [:delete 0 0 0 0] [:edit 3 0 1 1] [:update-main 3] [:update-main 0 0 0 0] + [:resize 6 0 0 0] [:nest 16 0 0 0] [:swap 16 0 0 0] [:detach 2 0 0 0] [:style 8 20 2 0] + [:reset 13 0 0 0]]}))))