From ec6c21c5a221e07eb4f2da2196a9cd8a98cb7597 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 27 Aug 2026 20:14:54 +0200 Subject: [PATCH] Sort the invoice customer dropdown alphabetically The customers endpoint returns rows in creation order, and the invoice editor rendered that order straight into the select, so the list got harder to scan as it grew. Sort by name with localeCompare using the same numeric/base-sensitivity options the invoice table already uses, so casing is ignored and accented names sort next to their base letter rather than after Z. Fixes #131 Co-Authored-By: Claude Opus 5 --- frontend/src/lib/components/InvoiceEditor.svelte | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/InvoiceEditor.svelte b/frontend/src/lib/components/InvoiceEditor.svelte index 7815ff1..99918a6 100644 --- a/frontend/src/lib/components/InvoiceEditor.svelte +++ b/frontend/src/lib/components/InvoiceEditor.svelte @@ -55,7 +55,17 @@ ], ); - let customers = $derived(data.customers || []); + // The API returns customers in creation order; sorting by name keeps the + // dropdown scannable once the list grows (locale-aware, so accented names + // land next to their base letter instead of after Z). + let customers = $derived( + [...(data.customers || [])].sort((a: any, b: any) => + String(a?.name || "").localeCompare(String(b?.name || ""), undefined, { + numeric: true, + sensitivity: "base", + }), + ), + ); let products = $derived(data.products || []); let taxDefinitions = $derived(data.taxDefinitions || []);