Skip to content

Fix sort order after column reorder on page reload#1346

Merged
jbtronics merged 2 commits intoPart-DB:masterfrom
wschopohl:col-reorder-bug
May 3, 2026
Merged

Fix sort order after column reorder on page reload#1346
jbtronics merged 2 commits 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 (6330b71) to head (9ad63f0).
⚠️ Report is 43 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1346      +/-   ##
============================================
- Coverage     57.46%   57.20%   -0.26%     
  Complexity     8410     8410              
============================================
  Files           616      616              
  Lines         27722    27117     -605     
============================================
- Hits          15930    15512     -418     
+ Misses        11792    11605     -187     

☔ 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.

@jbtronics
Copy link
Copy Markdown
Member

Looks good.
Thanks.

@jbtronics jbtronics merged commit 673d5b5 into Part-DB:master May 3, 2026
16 checks passed
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.

2 participants