mirror of
https://github.com/penpot/penpot.git
synced 2026-11-21 01:22:01 +00:00
🐛 Keep the size of an absolute fill child of a grid
A fill child of a grid takes the size of its content, which the grid's fill then fits to its cell. An absolute child is not filled by the grid, and the content of a grid whose flex columns span its width is that width and its padding, so an absolute fill board of a grid grew by its padding at every layout pass and never settled. An absolute child keeps its size. Benchmark (bench-components, run alone): | world | baseline | now | mean | ratio | |------------------------------------+----------+---------+---------+-------| | deepest-edit-through-three-levels | 35.215 | 23.593 | 26.323 | 0.67 | | edit-through-a-chain-of-dependents | 68.931 | 50.077 | 55.477 | 0.73 | | library-update-into-copies | 83.083 | 50.157 | 52.815 | 0.6 | | main-edit-among-many-shapes | 4.837 | 2.511 | 3.077 | 0.52 | | main-edit-into-10-copies | 1.79 | 1.172 | 1.215 | 0.65 | | main-edit-into-100-copies | 15.415 | 9.878 | 12.423 | 0.64 | | main-edit-into-1000-copies | 153.086 | 123.768 | 175.446 | 0.81 | | variant-switch-into-copies | 32.052 | 21.933 | 22.474 | 0.68 | AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
dea20dfc15
commit
44d13cdd14
@ -223,7 +223,8 @@
|
||||
"Calculates the modifiers to adjust the bounds for auto-width/auto-height
|
||||
shapes. A fill child of a grid takes the size of its content, unless it
|
||||
is turned in the grid: the grid's fill then sizes it along the grid's
|
||||
axes, and its content's size counts as its minimum there."
|
||||
axes, and its content's size counts as its minimum there. An absolute
|
||||
child keeps its size: the grid does not fill it."
|
||||
[objects bounds parent]
|
||||
(let [parent-id (:id parent)
|
||||
parent-bounds (get bounds parent-id)
|
||||
@ -250,7 +251,9 @@
|
||||
(remove ctl/position-absolute?)
|
||||
(remove gco/invalid-geometry?))
|
||||
|
||||
;; an absolute child is neither placed nor filled by the grid
|
||||
grid-fill? (and (ctl/grid-layout? objects (:parent-id parent))
|
||||
(not (ctl/position-absolute? parent))
|
||||
(not (turned-in-parent? objects bounds parent-id)))
|
||||
auto? (or (ctl/auto? parent)
|
||||
(and grid-fill? (ctl/fill? parent)))
|
||||
|
||||
@ -4308,6 +4308,13 @@
|
||||
:grid-empty false :layout-copies false :text true}]
|
||||
:ops [[:switch 11] [:switch 5] [:nest 17] [:add-child 15] [:rotate 15] [:style 12 9 1] [:paste 12]]}))))
|
||||
|
||||
(t/deftest generated-an-absolute-fill-board-in-a-grid-keeps-its-size
|
||||
;; a grid board set to fill a grid cell and then made absolute is no longer
|
||||
;; filled by that grid: its layout settles at its size
|
||||
(t/is (map? (cg/run {:world [2 1 {:variants true :text-styles true :layout :grid :library true
|
||||
:rich-variants true :layout-children true :layout-copies true :text true}]
|
||||
:ops [[:remove-child 5 0 0 0] [:style 2 29 1] [:style 5 35 1]]}))))
|
||||
|
||||
(t/deftest generated-an-ungroup-gives-a-grid-copy-with-its-own-cells-its-main-tracks
|
||||
;; a grid copy with its own cells and direction but its main's tracks
|
||||
;; takes the tracks an ungroup in the main adds before placing the shapes
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user