Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions organizer/src/webroot/js/tableSorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ document.addEventListener('DOMContentLoaded', () => {
// Toggle sort direction
sortDirection = sortDirection === 'asc' ? 'desc' : 'asc';

// Sort rows by the data-last-email-timestamp attribute
rows.sort((a, b) => {
// Separate visible and hidden rows to preserve filter state
const visibleRows = rows.filter(row => row.style.display !== 'none');
const hiddenRows = rows.filter(row => row.style.display === 'none');

// Sort only the visible rows by the data-last-email-timestamp attribute
visibleRows.sort((a, b) => {
const aTimestamp = parseInt(a.getAttribute('data-last-email-timestamp') || '0', 10);
const bTimestamp = parseInt(b.getAttribute('data-last-email-timestamp') || '0', 10);

Expand All @@ -64,12 +68,16 @@ document.addEventListener('DOMContentLoaded', () => {
// Remove all rows from the table
allRows.forEach(row => row.remove());

// Re-append header row first, then data rows
// Re-append header row first, then visible rows, then hidden rows
if (headerRow) {
tbody.appendChild(headerRow);
}

rows.forEach(row => {
visibleRows.forEach(row => {
tbody.appendChild(row);
});

hiddenRows.forEach(row => {
tbody.appendChild(row);
});

Expand Down
Loading