diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 80b18d3bf9..21c374e3e8 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -2524,8 +2524,9 @@ (defn- reset-layout-item "Give a reset head the layout item values it inherits: those of its ref - when its parent is the copy of the ref's layout parent. Sync passes them - from parent to children, so the reset of the head alone keeps them." + when its parent is the copy of the ref's layout parent, or a swapped head + whose main is that parent. Sync passes them from parent to children, so + the reset of the head alone keeps them." [changes file libraries container shape-id] (let [objects (pcb/get-objects changes) shape (get objects shape-id) @@ -2533,8 +2534,12 @@ ref (when (and (:layout parent) (:shape-ref parent)) (ctf/find-ref-shape file (assoc container :objects objects) libraries shape :include-deleted? true :with-context? true)) - ref-parent (get-in (meta ref) [:container :objects (:parent-id ref)])] - (if (and ref (:layout ref-parent) (= (:id ref-parent) (:shape-ref parent))) + ref-parent (get-in (meta ref) [:container :objects (:parent-id ref)]) + ;; whether sync pairs the parent with the ref's parent + paired? (or (= (:id ref-parent) (:shape-ref parent)) + (and (ctk/main-instance? ref-parent) + (= (:component-id ref-parent) (:component-id parent))))] + (if (and ref (:layout ref-parent) paired?) (pcb/update-shapes changes [shape-id] #(propagate-attrs % ref layout-child-attrs false) {:ignore-touched true}) changes))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index f5ed77ea26..3a9ae9eea0 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -2151,6 +2151,14 @@ :layout-children true :grid-empty true :layout-copies true :text true}] :ops [[:make-variant 1] [:style 4 29 1] [:style 7 12] [:update-main]]})))) +(t/deftest resetting-a-nested-copy-of-a-swapped-layout-head-restores-its-sizing + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff true + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty false :layout-copies true :text true}] + :ops [[:variant-property 5 1 3] [:variant-property 0 6 3] [:combine 6] + [:add-variant 0 6 7] [:combine 4 4 7] [:resize 3 7 4] [:switch 6] [:delete 5] + [:restore 0 5 7 5] [:swap 1 3 1 5] [:style 0 30 1] [:reset 3]]})))) + (t/deftest moving-a-flex-copy-child-after-a-switch-resized-its-sibling-authors-no-geometry (t/is (map? (cg/run {:world [1 2 {:variants true :text-styles false :layout :flex :variant-diff false :layout-item-margins false :grid-square false :rich-variants true