Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Files.App.Controls/BreadcrumbBar/BreadcrumbBarLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ protected override Size MeasureOverride(NonVirtualizingLayoutContext context, Si
var accumulatedSize = new Size(0, 0);
_availableSize = availableSize;

// Ensure we have a minimum size to prevent DivideByZeroException in WinUI
// When availableSize has zero dimensions, provide a minimal positive size for measurement
var measureSize = new Size(
Math.Max(availableSize.Width, 1.0),
Math.Max(availableSize.Height, 1.0)
);

var indexAfterEllipsis = GetFirstIndexToRender(context);

// Go through all items and measure them
for (int index = 0; index < context.Children.Count; index++)
{
if (context.Children[index] is BreadcrumbBarItem breadcrumbItem)
{
breadcrumbItem.Measure(availableSize);
breadcrumbItem.Measure(measureSize);
accumulatedSize.Width += index < indexAfterEllipsis ? 0 : breadcrumbItem.DesiredSize.Width;
accumulatedSize.Height = Math.Max(accumulatedSize.Height, breadcrumbItem.DesiredSize.Height);
}
Expand Down Expand Up @@ -98,6 +105,10 @@ private int GetFirstIndexToRender(NonVirtualizingLayoutContext context)
var itemCount = context.Children.Count;
var accumulatedWidth = 0d;

// Handle zero or negative available width - hide all items
if (_availableSize.Width <= 0)
return itemCount;

// Go through all items from the last item
for (int index = itemCount - 1; index >= 0; index--)
{
Expand Down
Loading