From 8425d2a6aa8bf0998b53c3694fb13abe08b2f927 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Tue, 16 Aug 2022 15:48:46 +0200 Subject: [PATCH] layout: ensure Flex{Alignment: Middle} respects minimum constraint Before this change, the middle alignment would align according to the widest child. This change aligns according to the widest child or minimum constraint, whichever is largest. Signed-off-by: Elias Naur --- layout/flex.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/flex.go b/layout/flex.go index 30472492..0f0dc3c3 100644 --- a/layout/flex.go +++ b/layout/flex.go @@ -142,7 +142,7 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions { children[i].call = c children[i].dims = dims } - var maxCross int + maxCross := crossMin var maxBaseline int for _, child := range children { if c := f.Axis.Convert(child.dims.Size).Y; c > maxCross {