mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Give a re-headed swapped copy its new main's placement
A swapped nested head pasted out of every copy level becomes a plain copy of the component it shows. It kept as overrides the placement that differs from its new main, but left the rest as it was: a nil constraint, the default of its old board, kept meaning something else at the page root while its main states `:left`, so it no longer matched its main (F592). Users reach it by copying such a copy and pasting it. `rehead-swapped` now gives the placement attributes it does not override the new main's values. Found by a fresh gate round (seed 20261117, library property). Test (swap-group-test, fails before the fix): `paste-gives-a-swapped-head-the-placement-of-its-new-main`. Benchmark (bench-components, alone): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+---------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 20.608 | 21.876 | 0.59 | | edit-through-a-chain-of-dependents | 68.931 | 42.175 | 44.133 | 0.61 | | library-update-into-copies | 83.083 | 50.77 | 52.63 | 0.61 | | main-edit-among-many-shapes | 4.837 | 2.352 | 2.51 | 0.49 | | main-edit-into-10-copies | 1.79 | 1.043 | 1.087 | 0.58 | | main-edit-into-100-copies | 15.415 | 10.185 | 10.428 | 0.66 | | main-edit-into-1000-copies | 153.086 | 101.226 | 105.622 | 0.66 | | variant-switch-into-copies | 32.052 | 22.621 | 23.491 | 0.71 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
f1f5ed862a
commit
7aa788c6e5
@ -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))))
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user