mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Place a reset nested copy beside the parent its layout moved
A reset nested copy under a copy that keeps its own geometry takes the placement that a sync of that copy gives its subtree. That sync places the reset head's parent before the parent's layout does, so when a copy layout placed the parent elsewhere than its main, as a reversed flex direction does, the reset head moved by the parent's main offset and was left apart from the parent it belongs to. The placement follows the parent where it is: it moves by the offset between the parent's proposed and actual places. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 18.762 | 0.53 | | edit-through-a-chain-of-dependents | 68.931 | 39.749 | 0.58 | | library-update-into-copies | 83.083 | 46.429 | 0.56 | | main-edit-among-many-shapes | 4.837 | 2.079 | 0.43 | | main-edit-into-10-copies | 1.79 | 0.943 | 0.53 | | main-edit-into-100-copies | 15.415 | 8.922 | 0.58 | | main-edit-into-1000-copies | 153.086 | 91.435 | 0.60 | | variant-switch-into-copies | 32.052 | 20.56 | 0.64 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
babab40c93
commit
8f0b749563
@ -2157,11 +2157,16 @@
|
||||
(pcb/with-objects objects))
|
||||
file (assoc libraries (:id file) file)
|
||||
container (:id head) false)
|
||||
placed (pcb/get-objects proposal)]
|
||||
placed (pcb/get-objects proposal)
|
||||
;; the sync places the parent before its layout does; follow the parent where it is
|
||||
offset (if-let [proposed (get placed (:id parent))]
|
||||
(gpt/subtract (first (:points parent)) (first (:points proposed)))
|
||||
(gpt/point 0 0))]
|
||||
(pcb/update-shapes
|
||||
changes (cfh/get-children-ids-with-self objects shape-id)
|
||||
(fn [shape]
|
||||
(let [expected (get placed (:id shape))
|
||||
(let [expected (cond-> (get placed (:id shape))
|
||||
(not (gpt/close? offset (gpt/point 0 0))) (gsh/move offset))
|
||||
attrs (cond-> placement-geometry-attrs
|
||||
(= :path (:type shape)) (conj :content))]
|
||||
(if (= (:type shape) (:type expected))
|
||||
|
||||
@ -1084,3 +1084,12 @@
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff false
|
||||
:rich-variants true :layout-copies true :text true}]
|
||||
:ops [[:nest 6 0 0 0] [:style 8 1 1] [:switch 4 0 0 0]]}))))
|
||||
|
||||
(t/deftest generated-reset-in-a-reversed-flex-copy-stays-with-its-parent
|
||||
;; a copy inside a nested copy that a resized, reversed flex copy places
|
||||
;; elsewhere than its main is reset beside that parent
|
||||
(t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :layout :flex :library true :rich-variants true
|
||||
:layout-copies true :text true}]
|
||||
:ops [[:edit 18 0 0 0] [:delete 0 0 0 0] [:edit 3 0 1 1] [:update-main 3] [:update-main 0 0 0 0]
|
||||
[:resize 6 0 0 0] [:nest 16 0 0 0] [:swap 16 0 0 0] [:detach 2 0 0 0] [:style 8 20 2 0]
|
||||
[:reset 13 0 0 0]]}))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user