diff --git a/common/src/app/common/logic/instances.cljc b/common/src/app/common/logic/instances.cljc index 18bd2c21f3..8b4bdb0891 100644 --- a/common/src/app/common/logic/instances.cljc +++ b/common/src/app/common/logic/instances.cljc @@ -181,8 +181,19 @@ (when (and (contains? placement-groups group) (not= (value shape attr) (value main attr))) group)))) + (keys ctk/sync-attrs)) + ;; the placement it does not override is the new main's, as it shows + ;; it in its old position + followed (into [] + (filter (fn [attr] + (let [group (ctk/resolve-sync-group (:type shape) attr)] + (and (contains? placement-groups group) + (not (contains? groups group)) + (not (ctk/touched-group? shape group)))))) (keys ctk/sync-attrs))] - (cond-> (-> shape + (cond-> (-> (reduce (fn [shape attr] + (if (nil? (get main attr)) (dissoc shape attr) (assoc shape attr (get main attr)))) + shape followed) (assoc :shape-ref (:id main)) (ctk/remove-swap-group)) (seq groups) (update :touched (fnil into #{}) groups)))) diff --git a/common/test/common_tests/logic/swap_group_test.cljc b/common/test/common_tests/logic/swap_group_test.cljc index 9a910781b9..41a153b334 100644 --- a/common/test/common_tests/logic/swap_group_test.cljc +++ b/common/test/common_tests/logic/swap_group_test.cljc @@ -374,6 +374,18 @@ (t/is (not (ctk/swapped? head))) (t/is (= (thi/id :heart-rect) (:shape-ref child))))) +(t/deftest paste-gives-a-swapped-head-the-placement-of-its-new-main + ;; :copy-star shows the default constraint of its board, which :heart-main + ;; states explicitly; out of its copy it overrides none, so it takes the + ;; main's as it is, which keeps meaning the same at the page root + (let [file (-> (setup) + (ths/update-shape :heart-main :constraints-h :left)) + objects (copy-objects file :copy-star) + head (get objects (thi/id :copy-star))] + (t/is (= (thi/id :heart-main) (:shape-ref head))) + (t/is (= :left (:constraints-h head))) + (t/is (not (contains? (:touched head) :constraints-group))))) + (t/deftest paste-advances-a-deeper-swapped-head-by-position (let [file (setup-two-levels) dot-id (:id (first-child file :outer-star)) @@ -458,7 +470,6 @@ (t/is (= (thi/id :dot-main) (:shape-ref (get objects (:id dot))))) (t/is (= (thi/id :dot-heart) (:shape-ref (get objects (:id heart))))))) - (t/deftest duplicate-keeps-the-swap (let [file (-> (setup) (tho/duplicate-shape :copy)