mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Keep the children of a copy sized on its own when its main fills
A nested copy made absolute in a copy keeps its own geometry. Its main was then set to fill a grid and shrank. Sync places the main's children like the copy: it resized the main to the copy's size, but the grid's reflow refilled it to its cell, and the move that lines the two up shifted the copy's children by the difference. The main's subtree is now resized out of its parent's layout, since the copy's size is its own and no layout of the main owns it. Benchmark (scripts/bench-components, lower quantile in ms): | world | baseline | now | ratio | |------------------------------------+----------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 18.99 | 0.54 | | edit-through-a-chain-of-dependents | 68.931 | 37.28 | 0.54 | | library-update-into-copies | 83.083 | 49.96 | 0.60 | | main-edit-among-many-shapes | 4.837 | 2.233 | 0.46 | | main-edit-into-10-copies | 1.79 | 1.017 | 0.57 | | main-edit-into-100-copies | 15.415 | 9.558 | 0.62 | | main-edit-into-1000-copies | 153.086 | 91.362 | 0.60 | | variant-switch-into-copies | 32.052 | 20.725 | 0.65 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
6e3c8b1cb2
commit
a7ae3140c5
@ -569,7 +569,9 @@
|
||||
objects
|
||||
(let [modif-tree (gm/set-objects-modifiers
|
||||
{(:id shape-main) {:modifiers (ctm/change-size shape-main width height)}}
|
||||
(reduce-kv #(d/update-when %1 %2 merge %3) objects authored))]
|
||||
;; the copy keeps its own size, which no layout of the main owns
|
||||
(-> (reduce-kv #(d/update-when %1 %2 merge %3) objects authored)
|
||||
(assoc-in [(:id shape-main) :layout-item-absolute] true)))]
|
||||
(reduce-kv (fn [objects id {:keys [modifiers]}]
|
||||
(d/update-when objects id gsh/transform-shape modifiers))
|
||||
objects
|
||||
|
||||
@ -973,3 +973,10 @@
|
||||
(t/is (map? (cg/run {:world [2 0 {:variants true :text-styles true :library true :rich-variants true
|
||||
:layout-copies true :text true}]
|
||||
:ops [[:switch 3 0 0 0] [:nest 9 0 0 0] [:edit 7 1 1 :copy-head] [:reset 7]]}))))
|
||||
|
||||
(t/deftest generated-copy-with-its-own-geometry-keeps-children-of-a-main-set-to-fill
|
||||
;; a nested copy made absolute in a copy keeps its size when its main is
|
||||
;; set to fill a grid; its children stay where the copy has them
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff false
|
||||
:rich-variants true :grid-empty true :layout-copies true :text true}]
|
||||
:ops [[:style 1 35 1] [:style 0 29 1]]}))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user