Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Problem

Clicking the "Last email" column header toggles the sort indicator but doesn't reorder rows when filters are active.

Issue: Sort arrow changes but rows remain in same order

Root Cause

tableSearch.js hides filtered rows via display: none. The sorting code was sorting all rows including hidden ones, then re-appending them to the DOM - which made hidden rows visible again, breaking the filter.

Changes

Modified organizer/src/webroot/js/tableSorting.js to partition rows before sorting:

// 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
visibleRows.sort((a, b) => { /* ... */ });

// Re-append: header → sorted visible rows → hidden rows

Verification

Before filtering:
Sorting works on all rows

With filter applied:
Only "Thread A" rows visible

Sorting while filtered (critical case):
Visible rows reorder, hidden rows stay hidden

Clear filter:
All rows present after clearing filter

Original prompt

This section details on the original issue you should resolve

<issue_title>Thread list - The sorting does not work</issue_title>
<issue_description>The arrow switches way, but nothing else happens
Image</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: HNygard <168380+HNygard@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix sorting functionality for thread list Fix thread list sorting with active filters Jan 26, 2026
Copilot AI requested a review from HNygard January 26, 2026 21:07
@HNygard HNygard marked this pull request as ready for review January 27, 2026 08:07
Copilot AI review requested due to automatic review settings January 27, 2026 08:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where clicking the "Last email" column header in the thread list would toggle the sort indicator but fail to reorder rows when filters were active. The root cause was that the sorting code was re-appending all rows (including hidden ones), which inadvertently made filtered rows visible again.

Changes:

  • Modified tableSorting.js to partition rows into visible and hidden before sorting
  • Sort operation now only reorders visible rows while preserving hidden rows at the end

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thread list - The sorting does not work

2 participants