From 87be31cbec3ccb30c4a66e003b7f79ce657e3e14 Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Fri, 27 May 2022 15:14:41 -0400 Subject: [PATCH] widget/material: ensure scrollbar within dimensions This commit fixes a visual-only bug in the ListStyle that could make the scrollbar float at the edge of the maximum constraints when the list did not occupy the full constraints. The list would still reserve layout space for the scrollbar in the correct position, but the scrollbar would not be displayed there. Signed-off-by: Chris Waldon --- widget/material/list.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/widget/material/list.go b/widget/material/list.go index bdc0fcd6..1c512098 100644 --- a/widget/material/list.go +++ b/widget/material/list.go @@ -281,7 +281,12 @@ func (l ListStyle) Layout(gtx layout.Context, length int, w layout.ListElement) // layout.Direction 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 + gtx.Constraints.Min = listDims.Size + if l.AnchorStrategy == Occupy { + min := l.state.Axis.Convert(gtx.Constraints.Min) + min.Y += barWidth + gtx.Constraints.Min = l.state.Axis.Convert(min) + } anchoring.Layout(gtx, func(gtx layout.Context) layout.Dimensions { return l.ScrollbarStyle.Layout(gtx, l.state.Axis, start, end) })