diff --git a/common/src/app/common/test_helpers/composable/gen.cljc b/common/src/app/common/test_helpers/composable/gen.cljc index c4f7cc7272..743db9f672 100644 --- a/common/src/app/common/test_helpers/composable/gen.cljc +++ b/common/src/app/common/test_helpers/composable/gen.cljc @@ -1146,14 +1146,16 @@ head (get after-objects new-head) main (get after-objects (:shape-ref head)) model (shadow/duplicate model objects id (:objects (thf/current-page (tm/file after))) new-head)] - ;; a copy pasted on the page keeps the orientation and size it showed, - ;; which its main's need not be + ;; a copy pasted on the page keeps the geometry it showed: what it + ;; authored, now where it lands, and the orientation and size another + ;; parent gave it, which its main's need not be (cond-> model (and (= kind :paste) head main (:shape-ref head) - (not (get-in model [new-head :geometry-group])) - (or (not (gmt/close? (or (:transform head) (gmt/matrix)) (or (:transform main) (gmt/matrix)))) - (not (mth/close? (:width (:selrect head)) (:width (:selrect main)) 0.01)) - (not (mth/close? (:height (:selrect head)) (:height (:selrect main)) 0.01)))) + (or (get-in model [new-head :geometry-group]) + (and (not (cfh/root? (get objects (:parent-id shape)))) + (or (not (gmt/close? (or (:transform head) (gmt/matrix)) (or (:transform main) (gmt/matrix)))) + (not (mth/close? (:width (:selrect head)) (:width (:selrect main)) 0.01)) + (not (mth/close? (:height (:selrect head)) (:height (:selrect main)) 0.01)))))) (assoc-in [new-head :geometry-group] (shadow/author-geometry head nil)))) (:swap :switch) (let [after-objects (all-objects after) diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index 0f8dd60d25..9752e59ab7 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -188,7 +188,10 @@ (let [frame (get objects (:frame-id shape))] (when-not (ctl/any-layout? frame) frame)) parent) - placed (when (and objects (not (:sized? (::position (meta expected))))) + ;; a layout places the shape, whatever place it authored before + laid-out (and objects (ctl/any-layout-immediate-child? objects shape) + (not (ctl/position-absolute? shape))) + placed (when (and objects (not laid-out) (not (:sized? (::position (meta expected))))) (authored-placement expected parent shape)) ;; an authored size follows its parent's later resizes through its ;; constraints too, though its place is not authored diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index c76250c51c..0c461fc29a 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -4286,3 +4286,11 @@ :rich-variants true :layout-children false :grid-empty false :layout-copies true :text true}] :ops [[:style 14 11 1] [:text-style 14 0 1] [:nest 7] [:switch 9] [:switch 9]]})))) + +(t/deftest generated-a-copy-shape-ungrouped-into-a-grid-is-placed-by-it + ;; a copy shape that authored its place, then taken into a grid board by + ;; an ungroup of its main, is placed by that grid + (t/is (map? (cg/run {:world [2 2 {:variants true :rich-variants true :text true :layout :grid + :layout-copies true :layout-children false}] + :ops [[:transform 7 0 0 8] [:detach 6 0 0 0] [:add-child 0] [:structure 0 2 0] + [:sync 0 0 0 0]]}))))