diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 493a87336d..46d3a2de23 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -710,12 +710,20 @@ (not (and ignore-geometry is-geometry?))) ;; a text's content touches the groups of what the edit changes - ;; in it, and none when it changes nothing a copy can override + ;; in it, and none when it changes nothing a copy can override; a + ;; copy child taken out of its layout's flow keeps the place the + ;; layout gave it, as its own geometry content-groups (when (and may-touch? group (not equal?)) - (if (and (= type :text) (= attr :content)) + (cond + (and (= type :text) (= attr :content)) (let [groups (cttx/changed-groups (:content shape) val)] (cond-> groups (seq groups) (conj group))) + + (and (= attr :layout-item-absolute) (true? val)) + #{group :geometry-group} + + :else #{group})) token-groups diff --git a/common/test/common_tests/logic/comp_touched_test.cljc b/common/test/common_tests/logic/comp_touched_test.cljc index ae8dc29763..ce0d5b6429 100644 --- a/common/test/common_tests/logic/comp_touched_test.cljc +++ b/common/test/common_tests/logic/comp_touched_test.cljc @@ -351,3 +351,20 @@ file' (thf/apply-changes file changes)] (t/is (= #{:shadow-group group} (:touched (ths/get-shape file' :copy-child))) (name attr))))) + +(t/deftest a-copy-child-made-absolute-keeps-its-place-as-an-override + (let [file (-> (thf/sample-file :file1) + (tho/add-simple-component-with-copy :component1 :main-root :main-child :copy-root + :copy-root-params {:children-labels [:copy-child]}) + (ths/update-shape :main-root :layout :flex) + (ths/update-shape :copy-root :layout :flex)) + page (thf/current-page file) + copy-child (ths/get-shape file :copy-child) + changes (cls/generate-update-shapes (pcb/empty-changes nil (:id page)) + #{(:id copy-child)} + #(assoc % :layout-item-absolute true) + (:objects page) + {}) + file' (thf/apply-changes file changes)] + (t/is (= #{:layout-item-absolute :geometry-group} + (:touched (ths/get-shape file' :copy-child)))))) diff --git a/common/test/common_tests/logic/composable_gen_test.cljc b/common/test/common_tests/logic/composable_gen_test.cljc index 5948466ad0..76dcbf4219 100644 --- a/common/test/common_tests/logic/composable_gen_test.cljc +++ b/common/test/common_tests/logic/composable_gen_test.cljc @@ -851,3 +851,12 @@ [:undo] [:redo] [:reset 0] [:sync 1] [:switch 1 0 0 0] [:rotate 1 0 0 0] [:duplicate 0 0 0 0] [:reset 2 0 0 0] [:redo 0 0 0 0]]})))) + +(t/deftest generated-copy-child-made-absolute-keeps-its-own-layouts-place + ;; the copy's own gap places its Rectangle, which stays there as absolute + (let [result (cg/run {:world [2 0 {:layout :grid :grid-square true :layout-children true :layout-copies true}] + :ops [[:style 2 11 1] [:style 6 35 1]]}) + objects (:objects (thf/current-page (tm/file (:situation result)))) + child (some #(when (:layout-item-absolute %) %) (vals objects))] + (t/is (:shape-ref child)) + (t/is (contains? (:touched child) :geometry-group))))