mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Take no size from a copy that its own layout sizes on update-main
A detach can leave a nested copy child with its geometry touched. When the main then makes that child fill, the copy's own flex gives it its width. Update-main pushed that width, and the sizing rule, seeing the touched geometry, fixed the main child's sizing, though the copy never sized the child itself. The copy and its main lost the fill. pushed-size-sizing now takes no size from a copy whose own layout fills or hugs it on that axis. Test: updating-a-main-whose-copy-fills-a-child-of-touched-geometry-keeps- its-fill (the variant gate program of round 13, seed 333977410). Common suite: 2430 tests, 0 failures. Benchmark (scripts/bench-components, ms, lower 2.5% quantile): | :world | :baseline | :now | :mean | :ratio | |------------------------------------+-----------+---------+---------+--------| | deepest-edit-through-three-levels | 35.215 | 21.778 | 23.308 | 0.62 | | edit-through-a-chain-of-dependents | 68.931 | 44.155 | 44.668 | 0.64 | | library-update-into-copies | 83.083 | 52.14 | 54.92 | 0.63 | | main-edit-among-many-shapes | 4.837 | 2.324 | 2.463 | 0.48 | | main-edit-into-10-copies | 1.79 | 0.979 | 1.028 | 0.55 | | main-edit-into-100-copies | 15.415 | 9.396 | 9.878 | 0.61 | | main-edit-into-1000-copies | 153.086 | 110.162 | 113.117 | 0.72 | | variant-switch-into-copies | 32.052 | 22.141 | 22.813 | 0.69 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
3105afa9ae
commit
c17ea582b0
@ -944,7 +944,8 @@
|
||||
`inst-objects`, into it: fixed on each axis that a layout sizes (fill or
|
||||
auto) and that the push resizes, or on both when it turns the shape in its
|
||||
parent, since a layout resizes a turned child. Only a copy that authors
|
||||
its geometry resizes or turns the main; the layout sizes the rest. A shape
|
||||
its geometry resizes or turns the main, and no copy authors a size its own
|
||||
layout gives it; the layout sizes the rest. A shape
|
||||
that is not a layout drops the sizing, which leaves it fixed as its copies
|
||||
are. A sizing the copy authors is pushed as it is."
|
||||
[objects shape-main inst-objects shape-inst source]
|
||||
@ -958,11 +959,20 @@
|
||||
(gmt/multiply (gmt/inverse (axes-matrix (get objects (:parent-id shape)))))))
|
||||
turned? (not (gmt/unit? (gmt/multiply (in-parent inst-objects shape-inst)
|
||||
(gmt/inverse (in-parent objects shape-main)))))
|
||||
;; whether the copy's own layout gives it its size on an axis
|
||||
copy-sized? (fn [sizing]
|
||||
(let [value (get shape-inst sizing)]
|
||||
(or (and (contains? #{:fill :auto} value)
|
||||
(ctsl/any-layout-immediate-child? inst-objects shape-inst)
|
||||
(not (ctsl/position-absolute? shape-inst)))
|
||||
(and (= :auto value) (ctsl/any-layout? shape-inst)))))
|
||||
fix? (fn [sizing size]
|
||||
(and laid?
|
||||
(not (ctk/touched-group? shape-inst sizing))
|
||||
(contains? #{:fill :auto} (get shape-main sizing))
|
||||
(or turned? (not (mth/close? (get source size) (get shape-main size))))))
|
||||
(or turned?
|
||||
(and (not (copy-sized? sizing))
|
||||
(not (mth/close? (get source size) (get shape-main size)))))))
|
||||
fixed (when (ctsl/any-layout? shape-main) :fix)]
|
||||
(cond-> {}
|
||||
(fix? :layout-item-h-sizing :width) (assoc :layout-item-h-sizing fixed)
|
||||
|
||||
@ -2152,6 +2152,12 @@
|
||||
:layout-children true :grid-empty true :layout-copies true :text true}]
|
||||
:ops [[:make-variant 1] [:style 4 29 1] [:style 7 12] [:update-main]]}))))
|
||||
|
||||
(t/deftest updating-a-main-whose-copy-fills-a-child-of-touched-geometry-keeps-its-fill
|
||||
(t/is (map? (cg/run {:world [1 2 {:variants true :text-styles false :layout :flex :variant-diff false
|
||||
:layout-item-margins false :grid-square false :rich-variants false
|
||||
:layout-children true :grid-empty false :layout-copies false :text true}]
|
||||
:ops [[:style 4 21 1] [:detach 8] [:style 0 29 1] [:update-main]]}))))
|
||||
|
||||
(t/deftest resetting-a-nested-copy-of-a-swapped-layout-head-restores-its-sizing
|
||||
(t/is (map? (cg/run {:world [2 2 {:variants true :text-styles true :layout :grid :variant-diff true
|
||||
:layout-item-margins false :grid-square false :rich-variants true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user