mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Keep a copy child made absolute where its layout placed it
A copy child taken out of its layout's flow stays where the layout put it, which can differ from its main's place when the copy has its own layout values. Making it absolute now marks its geometry as an override too, so sync keeps that place instead of moving it to the main's. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+--------+-------| | deepest-edit-through-three-levels | 35.215 | 18.081 | 0.51 | | edit-through-a-chain-of-dependents | 68.931 | 35.42 | 0.51 | | library-update-into-copies | 83.083 | 45.335 | 0.55 | | main-edit-among-many-shapes | 4.837 | 2.3 | 0.48 | | main-edit-into-10-copies | 1.79 | 0.905 | 0.51 | | main-edit-into-100-copies | 15.415 | 8.714 | 0.57 | | main-edit-into-1000-copies | 153.086 | 88.228 | 0.58 | | variant-switch-into-copies | 32.052 | 20.752 | 0.65 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
3e934593d1
commit
c09fb3d26c
@ -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
|
||||
|
||||
@ -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))))))
|
||||
|
||||
@ -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))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user