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 <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2021-07-12 13:10:24 -04:00
committed by Elias Naur
parent d9a0b4be76
commit 78235baaa5
+4
View File
@@ -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)
})