Merge pull request #3719 from penpot/alotor-fix-fill-problem

🐛 Fix problem with size 100% and hidden layers
This commit is contained in:
Aitor Moreno 2023-10-20 10:26:41 +02:00 committed by GitHub
commit 14a3a8a527
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 25 deletions

View file

@ -6,7 +6,7 @@
(ns app.common.geom.shapes.min-size-layout
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.geom.shapes.flex-layout.bounds :as fb]
[app.common.geom.shapes.flex-layout.layout-data :as fd]
[app.common.geom.shapes.grid-layout.bounds :as gb]
@ -19,10 +19,10 @@
[child child-bounds bounds objects]
(let [min-width
(cond
(and (ctl/fill-width? child)
(ctl/flex-layout? child))
(let [children (->> child :shapes (map (d/getf objects)))]
(gpo/width-points (fb/layout-content-bounds bounds child children objects)))
(and (ctl/fill-width? child) (ctl/flex-layout? child))
(let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
(max (ctl/child-min-width child)
(gpo/width-points (fb/layout-content-bounds bounds child children objects))))
(and (ctl/fill-width? child)
(ctl/grid-layout? child))
@ -30,7 +30,8 @@
(->> (cph/get-immediate-children objects (:id child) {:remove-hidden true})
(map #(vector @(get bounds (:id %)) %)))
layout-data (gd/calc-layout-data child @(get bounds (:id child)) children bounds objects true)]
(gpo/width-points (gb/layout-content-bounds bounds child layout-data)))
(max (ctl/child-min-width child)
(gpo/width-points (gb/layout-content-bounds bounds child layout-data))))
(ctl/fill-width? child)
(ctl/child-min-width child)
@ -44,15 +45,18 @@
(let [min-height
(cond
(and (ctl/fill-height? child) (ctl/flex-layout? child))
(gpo/height-points (fb/layout-content-bounds bounds child (->> child :shapes (map (d/getf objects))) objects))
(let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})]
(max (ctl/child-min-height child)
(gpo/height-points (fb/layout-content-bounds bounds child children objects))))
(and (ctl/fill-height? child) (ctl/grid-layout? child))
(let [children (->> child :shapes
(map (d/getf objects))
(map (fn [child] [@(get bounds (:id child)) child])))
(let [children
(->> (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})
(map (fn [child] [@(get bounds (:id child)) child])))
layout-data (gd/calc-layout-data child (:points child) children bounds objects true)
auto-bounds (gb/layout-content-bounds bounds child layout-data)]
(gpo/height-points auto-bounds))
(max (ctl/child-min-height child)
(gpo/height-points auto-bounds)))
(ctl/fill-height? child)
(ctl/child-min-height child)