From 0a25cce9ce517b236075347891b43ea4d28fa45c Mon Sep 17 00:00:00 2001 From: Lucas Winther Date: Mon, 17 Aug 2026 18:31:18 +0200 Subject: [PATCH] fix(custom): list your own games first when adding an event Someone filling this form in by hand is usually doing it because the game isn't tracked, so making them scroll past nine that are gets the common case backwards. The default selection follows the top of the list rather than staying on whatever the feed happened to return first. The sort groups and does not reshuffle: tracked games keep their feed order behind the reader's own. Co-Authored-By: Claude Opus 5 (1M context) --- CLAUDE.md | 2 +- src/client/components/CustomForms.tsx | 12 +++++++-- test/custom-ui.test.tsx | 38 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 60668a4..2cd493f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -86,7 +86,7 @@ src/client/ React app, service worker, manifest lens.ts — who sees which rows (focus, outstanding, next-to-expire); pure scripts/ build-feed.ts, parse-fixture.ts (offline), refresh-sources.ts (fetches) serve.ts static server + /api/health -test/ 400 tests +test/ 401 tests fixtures// raw HTML + .expected.json per source — pinned, kept forever snapshots/ current page per source, rewritten by refresh — see its README ``` diff --git a/src/client/components/CustomForms.tsx b/src/client/components/CustomForms.tsx index 11a4cce..c6b1700 100644 --- a/src/client/components/CustomForms.tsx +++ b/src/client/components/CustomForms.tsx @@ -141,8 +141,16 @@ export function EventForm({ const start = fields(initial?.startsAt ?? null); const end = fields(initial?.endsAt ?? null); + // The reader's own games first, and so the default too. Someone filling this + // in by hand is usually doing it *because* the game isn't tracked; making + // them scroll past nine that are gets the common case backwards. Stable + // within each group, so the tracked ones keep their feed order. + const ordered = [...lanes].sort( + (a, b) => Number(isCustomGameId(b)) - Number(isCustomGameId(a)), + ); + const [game, setGame] = useState( - initial?.game ?? lanes[0] ?? Object.keys(customGames)[0] ?? "", + initial?.game ?? ordered[0] ?? Object.keys(customGames)[0] ?? "", ); const [title, setTitle] = useState(initial?.title ?? ""); const [type, setType] = useState(initial?.type ?? "other"); @@ -198,7 +206,7 @@ export function EventForm({ onChange={(e) => setGame(e.target.value)} className={inputClass()} > - {lanes.map((id) => ( + {ordered.map((id) => (