From 78235baaa541218bbc7db2c1f01b86934705a611 Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Mon, 12 Jul 2021 13:10:24 -0400 Subject: [PATCH] widget/material: ensure List handles zero minimum constraints This change ensures that the scrollbar anchors to the proper edge of the content even when the list was drawn with a zero minimum constraint. Without this, the layout.Direction used to anchor the scrollbar will choose to use the minimum size and anchor it to the opposite edge of the content. Signed-off-by: Chris Waldon --- widget/material/list.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/widget/material/list.go b/widget/material/list.go index b30515af..75183a46 100644 --- a/widget/material/list.go +++ b/widget/material/list.go @@ -271,6 +271,10 @@ func (l ListStyle) Layout(gtx layout.Context, length int, w layout.ListElement) majorAxisSize := l.state.Axis.Convert(listDims.Size).X start, end := fromListPosition(l.state.Position, length, majorAxisSize) anchoring.Layout(gtx, func(gtx layout.Context) layout.Dimensions { + // layout.Dimension respects the minimum, so ensure that the + // scrollbar will be drawn on the correct edge even if the provided + // layout.Context had a zero minimum constraint. + gtx.Constraints.Min = gtx.Constraints.Max return l.ScrollbarStyle.Layout(gtx, l.state.Axis, start, end) })