diff --git a/common/src/app/common/logic/libraries.cljc b/common/src/app/common/logic/libraries.cljc index 345cbf15ef..807315fd99 100644 --- a/common/src/app/common/logic/libraries.cljc +++ b/common/src/app/common/logic/libraries.cljc @@ -38,6 +38,7 @@ [app.common.types.text :as txt] [app.common.types.token :as cto] [app.common.types.typography :as cty] + [app.common.uuid :as uuid] [clojure.set :as set])) ;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default @@ -565,9 +566,10 @@ objects (let [modif-tree (gm/set-objects-modifiers {(:id shape-main) {:modifiers (ctm/change-size shape-main width height)}} - ;; the copy keeps its own size, which no layout of the main owns + ;; the subtree alone, under the root: no layout of the main's + ;; parent owns the copy's size (-> (reduce-kv #(d/update-when %1 %2 merge %3) objects authored) - (assoc-in [(:id shape-main) :layout-item-absolute] true)))] + (update (:id shape-main) assoc :parent-id uuid/zero)))] (reduce-kv (fn [objects id {:keys [modifiers]}] (d/update-when objects id gsh/transform-shape modifiers)) objects diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index b32ed9aedb..1010dc1dce 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -1187,3 +1187,13 @@ :grid-square false :library true :rich-variants true :layout-children false :grid-empty false :layout-copies true :text true}] :ops [[:nest 6 0 0 0] [:text 6 0 0 0] [:delete 6 0 0 0] [:swap 6 0 0 0] [:switch 0 0 0 0]]})))) + +(t/deftest generated-duplicate-in-a-grid-resizes-a-copy-subtree-alone + ;; a sync that resizes a copy in a grid lays out the copy's subtree while + ;; the grid has a duplicated child with no cell yet; the program reaches + ;; that sync on every other run, so it runs twice + (dotimes [_ 2] + (t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff false + :layout-item-margins false :grid-square false :rich-variants true + :layout-children false :grid-empty true :layout-copies true :text true}] + :ops [[:style 0 29 1] [:nest 9 0 0 0] [:duplicate 5 1 0 0]]})))))