diff --git a/common/src/app/common/test_helpers/composable/oracle.cljc b/common/src/app/common/test_helpers/composable/oracle.cljc index 293db99eca..a6f9a94900 100644 --- a/common/src/app/common/test_helpers/composable/oracle.cljc +++ b/common/src/app/common/test_helpers/composable/oracle.cljc @@ -552,13 +552,13 @@ (select-keys target [:component-id :component-file]))) :else - (let [source-parent (get source-objects (:parent-id source)) - item-group (.startsWith (name group) "layout-item-") + (let [item-group (.startsWith (name group) "layout-item-") intrinsic (and (:layout source) (#{:layout-item-h-sizing :layout-item-v-sizing} group) (#{:fix :auto} (get source group))) + ;; only a layout parent in the main pushes layout child groups push-item (or intrinsic - (and (not= id root-id) (:layout source-parent))) + (and (not= id root-id) (:layout (get objects (:parent-id target))))) target (if (and item-group (not push-item)) kept target) expected (if (= group :layout-grid-cells) (get (grid/remap-groups {group (shadow/values source group)} diff --git a/common/src/app/common/test_helpers/composable/shadow.cljc b/common/src/app/common/test_helpers/composable/shadow.cljc index 9a98a73196..c5a88cb446 100644 --- a/common/src/app/common/test_helpers/composable/shadow.cljc +++ b/common/src/app/common/test_helpers/composable/shadow.cljc @@ -449,12 +449,14 @@ main-parent (get before (:parent-id main-root) {}) ;; the way the rotation of `shape` stores its turn sign (geom/turn-sign shape) - ;; the turn the copy root inherits places it and is not pushed + ;; the turn the copy root inherits places it and is not pushed: + ;; all of a top root's that authors no geometry, else its parent's + inherits-all? (and (:component-root root) (not (get-in model [root-id :geometry-group]))) geometry (cond-> (values shape :geometry-group) - (and (:component-root root) (not (get-in model [root-id :geometry-group]))) + inherits-all? (in-orientation root main-root sign) - (and (not (:component-root root)) root-parent) + (and (not inherits-all?) root-parent) (in-orientation root-parent main-parent sign)) replaced (when (and (contains? groups :swap-group) (not= (:shape-ref shape) (:shape-ref updated))) @@ -501,10 +503,17 @@ ;; a variant main keeps its set's name, and the copy root its own kept-name (when (and (= id root-id) (:variant-id ref)) (:name-group groups)) groups (cond-> groups kept-name (dissoc :name-group)) + ;; only a layout parent pushes layout child groups; the copy keeps the others + kept-items (when (and (not= id root-id) (not (ctl/any-layout? (get after (:parent-id ref))))) + (into {} (filter #(.startsWith (name (key %)) "layout-item-")) groups)) + groups (apply dissoc groups (keys kept-items)) result (cond-> (dissoc result id) (and (contains? groups :swap-group) (not= (:component-id updated) (:component-id ref))) (assoc id {:swap-group {}}) + + (seq kept-items) + (update id merge kept-items) kept-name (assoc-in [id :name-group] kept-name) (and (:shape-ref ref) (seq groups)) @@ -816,14 +825,14 @@ :else (same? (get old-placed attr) (get placed attr)))) - ;; the same turn of two mirrors differs where they point - ;; their axes apart + ;; a mirror stores its turn either way: the turns of two + ;; mirrors differ where they point their axes apart differs? (fn [attr] - (or (not (same? (get old attr) (get placed attr))) - (and (= attr :rotation) (not root?) old-parent new-parent - (mirrored? old) (mirrored? placed) - (not (geom/same-placed-axes? old old-parent new-parent - main (get after (:parent-id main)) new-parent))))) + (if (and (= attr :rotation) (not root?) old-parent new-parent + (mirrored? old) (mirrored? placed)) + (not (geom/same-placed-axes? old old-parent new-parent + main (get after (:parent-id main)) new-parent)) + (not (same? (get old attr) (get placed attr))))) carried (filter (fn [attr] (and (attribute-applicable? main attr) (agrees? attr) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index d24209727b..1300a85d40 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2201,6 +2201,13 @@ :ops [[:swap] [:make-variant 12] [:rotate 0 0 1] [:delete] [:transform 6 5] [:transform 3 9 7 13] [:switch]]})))) +(t/deftest switching-a-copy-carries-no-mirrored-turn-stored-the-other-way-in-the-model + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles false :layout :grid :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies false :text true}] + :ops [[:swap] [:make-variant 12] [:rotate] [:delete] [:transform 6 5] + [:transform 3 0 0 13] [:switch]]})))) + (t/deftest updating-a-turned-main-from-a-swapped-head-turns-the-new-head-with-its-parent (t/is (map? (cg/run {:world [3 2 {:variants true :text-styles false :layout :flex :variant-diff false :layout-item-margins false :grid-square false :rich-variants false @@ -2230,6 +2237,13 @@ [:add-variant] [:switch 22] [:duplicate 1] [:detach 20] [:text-style 23 0 1] [:switch 6] [:update-main 22]]})))) +(t/deftest updating-a-main-from-a-resized-root-keeps-the-turn-its-parent-gives-a-swapped-head + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout nil :variant-diff true + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty true :layout-copies false :text false}] + :ops [[:make-variant 3] [:nest 4] [:combine 4] [:rotate 2] [:detach 1] [:combine 3] + [:switch] [:update-main] [:detach 2] [:resize 2] [:switch 5] [:update-main]]})))) + (t/deftest pushing-a-grid-direction-orders-the-copies-like-the-reflowed-main (t/is (map? (cg/run {:world [3 2 {:variants true :text-styles false :layout :grid :variant-diff false :layout-item-margins false :grid-square true :rich-variants false