From 4d2d7c77d339a3817bc0ff6e4a34eeecdcbb36c4 Mon Sep 17 00:00:00 2001 From: Falkan Date: Fri, 20 Mar 2026 11:41:29 -0400 Subject: [PATCH] feat: initialize selected unit to base unit of first group on load On initial page load (before any user interaction), the converter now selects the base unit of the first visible group instead of the first unit in the alphabetical list. Falls back to units[0] if the group's baseUnitId is not found in the visible unit list. URL param ?from= override and shift+click behavior are unaffected. Co-Authored-By: Claude Opus 4.6 --- src/routes/+page.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 0909715..96c1550 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -31,10 +31,14 @@ let highlightedUnitId = $state(null); let yoloMode = $state(false); - // Initialize fromUnitId to first unit once data arrives + // Initialize fromUnitId to the base unit of the first visible group. + // Falls back to units[0] if no groups or the base unit isn't in the visible list. $effect(() => { if (fromUnitId === '' && units.length > 0) { - fromUnitId = units[0].id; + const firstGroupBaseId = groups.length > 0 ? groups[0].baseUnitId : null; + fromUnitId = (firstGroupBaseId && units.some((u) => u.id === firstGroupBaseId)) + ? firstGroupBaseId + : units[0].id; } });