From 08a73eb84caf85764268119a81f342e7242c065b Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Fri, 9 Jan 2026 16:38:16 -0500 Subject: [PATCH] fix: Improve Assigned To column sorting behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed sorting logic for the "Assigned To" column on dashboard: Problem: - "Unassigned" was sorted alphabetically with user names - Appeared randomly in middle of list (after 'S', before 'V') - Made it hard to find unassigned tickets when sorted Solution: - "Unassigned" tickets now always appear at end of list - Regardless of sort direction (A→Z or Z→A) - Assigned user names still sort normally among themselves - Example A→Z: Alice, Bob, Charlie... Unassigned - Example Z→A: Zack, Yolanda, Xavier... Unassigned This keeps unassigned tickets grouped together and predictable. Co-Authored-By: Claude Sonnet 4.5 --- assets/js/dashboard.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/assets/js/dashboard.js b/assets/js/dashboard.js index 9a93f69..852ce42 100644 --- a/assets/js/dashboard.js +++ b/assets/js/dashboard.js @@ -132,7 +132,7 @@ function sortTable(table, column) { rows.sort((a, b) => { const aValue = a.children[column].textContent.trim(); const bValue = b.children[column].textContent.trim(); - + // Check if this is a date column const headerText = headers[column].textContent.toLowerCase(); if (headerText === 'created' || headerText === 'updated') { @@ -140,18 +140,36 @@ function sortTable(table, column) { const dateB = new Date(bValue); return currentDirection === 'asc' ? dateA - dateB : dateB - dateA; } - + + // Special handling for "Assigned To" column + if (headerText === 'assigned to') { + const aUnassigned = aValue === 'Unassigned'; + const bUnassigned = bValue === 'Unassigned'; + + // Both unassigned - equal + if (aUnassigned && bUnassigned) return 0; + + // Put unassigned at the end regardless of sort direction + if (aUnassigned) return 1; + if (bUnassigned) return -1; + + // Otherwise sort names normally + return currentDirection === 'asc' + ? aValue.localeCompare(bValue) + : bValue.localeCompare(aValue); + } + // Numeric comparison const numA = parseFloat(aValue); const numB = parseFloat(bValue); - + if (!isNaN(numA) && !isNaN(numB)) { return currentDirection === 'asc' ? numA - numB : numB - numA; } - + // String comparison - return currentDirection === 'asc' - ? aValue.localeCompare(bValue) + return currentDirection === 'asc' + ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue); });