Skip to content

Fix sort order after column reorder on page reload#1346

Open
wschopohl wants to merge 1 commit intoPart-DB:masterfrom
wschopohl:col-reorder-bug
Open

Fix sort order after column reorder on page reload#1346
wschopohl wants to merge 1 commit intoPart-DB:masterfrom
wschopohl:col-reorder-bug

Conversation

@wschopohl
Copy link
Copy Markdown
Contributor

Summary

  • Fixes incorrect sort order when columns have been reordered via colReorder drag-and-drop and the page is reloaded
  • The saved sort state uses visual (post-reorder) column indices, but initial_order was sending them to the server as-is — the server interpreted them as original indices, sorting the wrong column
  • Uses the saved colReorder mapping to translate visual indices back to original indices before sending initial_order in the _init request

Steps to reproduce

  1. Open any DataTables view (e.g. parts list)
  2. Drag a column to reorder it
  3. Click a column header to sort
  4. Reload the page
  5. Before fix: wrong column is sorted. After fix: correct column is sorted.

When columns are reordered via colReorder and the page is reloaded,
the saved sort state uses visual column indices. These were sent
directly as initial_order to the server, which interprets them as
original indices — causing the wrong column to be sorted.

Use the saved colReorder mapping to translate visual indices back to
original indices before sending initial_order in the _init request.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.20%. Comparing base (a82d515) to head (31e3049).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1346      +/-   ##
============================================
- Coverage     57.22%   57.20%   -0.03%     
  Complexity     8410     8410              
============================================
  Files           616      616              
  Lines         27117    27117              
============================================
- Hits          15518    15512       -6     
- Misses        11599    11605       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant