From c0386f27bcd5124d5ca55a530ef36629a395983a Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 19 May 2026 09:49:40 -0400 Subject: [PATCH] =?UTF-8?q?fix(idaa):=20fix=20name=20A=E2=86=92Z=20/=20Z?= =?UTF-8?q?=E2=86=92A=20sort=20not=20applying=20in=20API=20revalidation=20?= =?UTF-8?q?path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The RE-SORT block after API revalidation only checked for 'name' (a legacy sort mode removed when sort_modes was introduced). 'name_asc' and 'name_desc' fell through to the else branch and were silently re-sorted chronologically by tmp_sort_1, overriding the user's selection. Updated to match the fast-path IDB sort logic which already handled all three modes correctly. Co-Authored-By: Claude Sonnet 4.6 --- .../idaa/(idaa)/recovery_meetings/+page.svelte | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/routes/idaa/(idaa)/recovery_meetings/+page.svelte b/src/routes/idaa/(idaa)/recovery_meetings/+page.svelte index e1922da4..456ca69f 100644 --- a/src/routes/idaa/(idaa)/recovery_meetings/+page.svelte +++ b/src/routes/idaa/(idaa)/recovery_meetings/+page.svelte @@ -322,11 +322,19 @@ async function handle_search_refresh(qry_key: string) { return true; }); - // RE-SORT: Ensure perfect chronological order even if API puts NULLs last (Refactored 2026-02-16) - if ($idaa_loc.recovery_meetings.qry__order_by === 'name') { + // RE-SORT: Match the fast-path IDB sort so stale/NULL API ordering is corrected. + // WHY: The RE-SORT previously only checked 'name' (a legacy mode that no longer + // exists in sort_modes). 'name_asc' and 'name_desc' fell through to the else + // branch and were silently re-sorted chronologically, ignoring the user's selection. + const sort_order = $idaa_loc.recovery_meetings.qry__order_by; + if (sort_order === 'name_asc' || sort_order === 'name') { api_results.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? '') ); + } else if (sort_order === 'name_desc') { + api_results.sort((a, b) => + (b.name ?? '').localeCompare(a.name ?? '') + ); } else { api_results.sort((a, b) => (b.tmp_sort_1 ?? '').localeCompare(a.tmp_sort_1 ?? '')