Sort the invoice customer dropdown alphabetically - #141
Merged
kittendevv merged 1 commit intoSep 7, 2026
Conversation
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 kittendevv#131 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #131
Problem
/api/v1/customersreturns rowsORDER BY created_at DESC, andInvoiceEditor.svelterenders that order straight into the customer<select>. On both/invoices/newand/invoices/[id]/editthe dropdown is therefore ordered newest-first, which gets harder to scan as the customer list grows.Change
One file. The
customersderived value inInvoiceEditor.sveltenow sorts a copy of the list by name, using the samelocaleCompareoptions the invoice table already uses inroutes/invoices/+page.svelte:Sorting client-side rather than in the SQL keeps the change scoped to the dropdown the issue is about. Changing
ORDER BYincontrollers/customers.tswould also flip the/customerslisting away from newest-first, and SQLiteCOLLATE NOCASEis ASCII-only, so accented names would sort after Z. Happy to move it into the query instead if you would rather have it apply everywhere.Testing
Ran the backend and the SvelteKit dev server locally with seven customers created in deliberately non-alphabetical order.
Before:
After:
Casing is ignored, so
alpha servicessorts first rather than last, andÄ/Ösort next toA/O.Also checked on
/invoices/[id]/editthat the list is sorted while the invoice's existing customer stays preselected, and that picking a different customer from the sorted dropdown saves correctly.bun run checkreports 0 errors,eslintis clean, andbun run buildsucceeds.prettier --checkflags the same 5 files it already flags on an unmodifiedmain; the changed file passes.