From 2e3ec03927e57ac94eb0be8aad00115a8f575714 Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 8 Sep 2026 18:41:14 +0200 Subject: [PATCH] Collapse stop groups by default on collection screen Drivers see a flat list of stops (suppliers / area clusters / POs) on first load and tap one to drill into its items. Previously every group auto-expanded on load, which buried the day at a glance under every item row. - Remove the three setExpanded*(allIds) auto-expand calls in loadItems - Empty Set() defaults keep state stable across refreshes and tab switches - expandAll() toolbar action still available for bulk-open - SupplierGroup / AreaGroup already render the collapsed preview line (first 3 items +N more) so the stop's contents stay visible without expanding --- app/page.tsx | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index e864aee..70c7cba 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -146,23 +146,15 @@ const loadItems = useCallback(async (showLoading = true) => { setItems(data); setFilteredItems(data); setCached(statusFilter, data); - const allSupplierIds = new Set(); - data.forEach(i => { - if (i.expand?.supplier?.id) allSupplierIds.add(i.expand.supplier.id); - }); - setExpandedSuppliers(allSupplierIds); - const allAreaIds = new Set(); - const clusters = clusterByProximity(data, 2); - clusters.forEach(c => allAreaIds.add(c.id)); - setExpandedAreas(allAreaIds); - // Auto-expand every PO sub-group on first load — drivers want to - // see all of a PO's items at once. Per-PO collapse is opt-in. - const allPoIds = new Set(); - data.forEach(i => { - const po = i.expand?.purchase_order; - allPoIds.add(po?.id || '__no_po__'); - }); - setExpandedPOs(allPoIds); + // Default to ALL groups collapsed. Drivers see a flat list of + // stops (suppliers / area clusters / POs) on first load and tap + // one to drill into its items — matches the "open the app, + // see your day" mental model. The "Show all" toolbar action + // (`expandAll`) is still available for the rare case where a + // driver wants everything expanded at once. + setExpandedSuppliers(new Set()); + setExpandedAreas(new Set()); + setExpandedPOs(new Set()); } catch (err) { console.error('Failed to load collections:', err); setError('Failed to load collections. Pull down to retry.');